ssh 无秘钥登录
三台centos 一台服务器192.168.2.152 一台客户端192.168.2.142 一台客户端192.168.2.151
(1)产生无密钥
[root@localhost ~]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
fa:65:a6:b8:6f:d1:f1:e0:40:2e:56:50:85:24:99:b5 root@localhost.localdomain
The key's randomart image is:
+--[ DSA 1024]----+
| oB+o. |
| o.+. |
| +E |
| o o o |
| . .S+ + |
| .. o . |
| . .+ |
| o.= |
| o++ |
+-----------------+
注意这里要默认敲三下回车
(2)查看产生的密钥 会产生两个文件一个id_dsa是密钥 一个id_dsa.pub是公钥
[root@localhost ~]# ls -l .ssh/
总用量 12
-rw-------. 1 root root 616 3月 28 23:12 authorized_keys
-rw-------. 1 root root 672 3月 29 02:35 id_dsa
-rw-r--r--. 1 root root 616 3月 29 02:35 id_dsa.pub
(3)把公钥发给其他服务器 要输入yes 和对向服务器的密码 这里特别注意如果对方ssh端口不是22,是其他端口用""括起来加-p
例如ssh-copy-id -i .ssh/id_dsa.pub "-p21 root@192.168.2.142"
[root@localhost ~]# ssh-copy-id -i .ssh/id_dsa.pub root@192.168.2.142
The authenticity of host '192.168.2.142 (192.168.2.142)' can't be established.
RSA key fingerprint is 1c:f0:dd:01:d6:58:5e:e9:07:37:b4:cc:c4:91:59:de.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.2.142' (RSA) to the list of known hosts.
root@192.168.2.142's password:
Now try logging into the machine, with "ssh 'root@192.168.2.142'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
(4)无密钥登录
[root@localhost ~]# ssh -p22 root@192.168.2.142
Last login: Sun May 6 20:15:39 2018 from 192.168.2.149
[root@localhost ~]# ip a | grep 192.168
inet 192.168.2.142/24 brd 192.168.2.255 scope global dynamic ens33
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
(5)传文件给客户端服务器 142 scp -p22端口 -rp r是目录 p是不改变文件属性 bao目录名字 root用户@ip : /root 存放的路径
[root@localhost ~]# scp -p22 -rp bao/ root@192.168.2.142:/root
apache-tomcat-9.0.5.tar.gz 100% 9254KB 9.0MB/s 00:00
grafana-3.1.1-1470047149.x86_64.rpm 100% 39MB 38.7MB/s 00:01
sunlogin_remoteclient_2.2.0.39537Beta.tar.gz 100% 2849KB 2.8MB/s 00:00
zabbix-3.4.7.tar.gz 100% 16MB 16.4MB/s 00:00
nginx-1.13.9.tar.gz 100% 971KB 971.5KB/s 00:00
jdk-8u162-linux-x64.tar.gz 100% 181MB 45.3MB/s 00:04
客户端查看
[root@localhost ~]# cd bao/
[root@localhost bao]# ls
apache-tomcat-9.0.5.tar.gz nginx-1.13.9.tar.gz
grafana-3.1.1-1470047149.x86_64.rpm sunlogin_remoteclient_2.2.0.39537Beta.tar.gz
jdk-8u162-linux-x64.tar.gz zabbix-3.4.7.tar.gz
(6)写到脚本里
给192.168.2.151服务传入公钥
vi ssh.sh
第一种方法
scp -p22 -rp bao/ root@192.168.2.142:/root
scp -p22 -rp bao/ root@192.168.2.151:/root
第二种方法
for n in 142 151
do
scp -p22 -rp bao/ root@192.168.2.$n:/root
done
sh ssh.sh
[root@localhost ~]# sh ssh.sh
apache-tomcat-9.0.5.tar.gz 100% 9254KB 9.0MB/s 00:00
grafana-3.1.1-1470047149.x86_64.rpm 100% 39MB 38.7MB/s 00:00
sunlogin_remoteclient_2.2.0.39537Beta.tar.gz 100% 2849KB 2.8MB/s 00:00
zabbix-3.4.7.tar.gz 100% 16MB 16.4MB/s 00:00
nginx-1.13.9.tar.gz 100% 971KB 971.5KB/s 00:00
jdk-8u162-linux-x64.tar.gz 100% 181MB 90.5MB/s 00:02
apache-tomcat-9.0.5.tar.gz 100% 9254KB 9.0MB/s 00:00
grafana-3.1.1-1470047149.x86_64.rpm 100% 39MB 38.7MB/s 00:01
sunlogin_remoteclient_2.2.0.39537Beta.tar.gz 100% 2849KB 2.8MB/s 00:00
zabbix-3.4.7.tar.gz 100% 16MB 16.4MB/s 00:00
nginx-1.13.9.tar.gz 100% 971KB 971.5KB/s 00:00
jdk-8u162-linux-x64.tar.gz 100% 181MB 60.3MB/s 00:03
ssh 无秘钥登录的更多相关文章
- ssh无秘钥登录
服务器1:172.16.20.136 服务器2:172.16.20.134 在服务器2上输入:ssh-keygen -t rsa (一路回车) scp /root/.ssh/id_ ...
- 配置SSH无秘钥登录
[hadoop@hadoop01 ~]$ cd .ssh [hadoop@hadoop01 .ssh]$ ls authorized_keys id_rsa id_rsa.pub known_host ...
- Linux SSH 免秘钥登录
SSH 免秘钥登录 ssh:是一种安全加密协议 ssh username@hostname ssh gongziyuan.com:以当前用户登录该机器(如果不是当前用户,需要这么干:ssh ...
- ansible-playbook 打通ssh无秘钥
建议参考: http://www.cnblogs.com/jackchen001/p/6514018.html 这个代码清晰,效果佳! 参考链接: http://www.cnblogs.com/cao ...
- linux下ssh免秘钥登录
1.检查防火墙是否关闭 (1)切换到root用户 (2)查看防火墙状态 service iptables status 这是没有关闭 (3)设置关闭 service iptables stop 2.检 ...
- SSH设置秘钥登录
设置 SSH 通过密钥登录 我们一般使用 PuTTY 等 SSH 客户端来远程管理 Linux 服务器.但是,一般的密码方式登录,容易有密码被暴力破解的问题.所以,一般我们会将 SSH 的端口设置为默 ...
- 配置SSH使用秘钥登录
使用密码远程登录ssh还是有比较大的风险的,比较安全的方法是使用秘钥登录 配置步骤如下 首先生成秘钥 ssh-keygen (直接默认回车也可以,生成的秘钥和公钥默认防止在/root/.ssh/文件 ...
- ssh免秘钥登录
简介 SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定:SSH 为建立在应用层基础上的安全协议.SSH 是目前较可靠,专为远程 ...
- Hadoop.2.x_无秘钥设置
1.在实际生产环境中为Hadoop配置无秘钥登录非常有必要 # 在没有配置时: [liuwl@linux-66-64 hadoop-2.5.0]$ jps 26163 Jps [liuwl@linux ...
随机推荐
- RTX腾讯通字体全变成横着的了
呵呵,简单,RTX字体选择里边的字体列表中同一种字体有些是带@符号的,有些没有带,记着选不带@号的就是头朝上的了.
- Python GUI之tkinter
https://blog.csdn.net/yingshukun/article/details/53985080 设置背景图:https://blog.csdn.net/rikkatakanashi ...
- Ubuntu18.04下安装搜狗输入法
Ubuntu18.04下安装搜狗输入法 第一步:安装 fcitx输入框架 sudo apt-get install fcitx 第二步:在官网下载 Linux 版本搜狗输入法 https://piny ...
- 银行卡卡bin
卡BIN指的是发卡行识别码,英文全称是 Bank Identification Number,缩写为 BIN.中文即“银行识别代码” 银行卡的卡号是标识发卡机构和持卡人信息的号码 一般是13-19位 ...
- learning makefile call func
- bootstrap全局样式二
加form-grope是为了以后更好的管理,一组form写一个form-grope 显示如下: 并排显示的话,给用户名前面再加一个div,再加horizontal,如下,并且加上control-lab ...
- netty解码器详解(小白也能看懂!)
什么是编解码器? 首先,我们回顾一下netty的组件设计:Netty的主要组件有Channel.EventLoop.ChannelFuture.ChannelHandler.ChannelPipe等. ...
- react系列笔记:第三记-redux-saga
github : https://github.com/redux-saga/redux-saga 文档:https://redux-saga.js.org/ redux-saga: redux中间 ...
- web前端框架之Vue hello world
[博客园cnblogs笔者m-yb原创,转载请加本文博客链接,笔者github: https://github.com/mayangbo666,公众号aandb7,QQ群927113708] http ...
- CSS1 !important
CSS1 !important 提升指定样式规则的应用优先权 ie6并不支持.还是会被后面的样式覆盖