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 ...
随机推荐
- Linuxpython3安装库
- Wincc报表+Listview使用
listview在Wincc中可以作为显示的控件,对于列表表头的定义如下所示: list的命名,点击属性,在对象名称中对其定义: 有了listview的定义,就可以使用VBS对其表头的定义.具体代码如 ...
- NPM 报错--fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module
fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module 解决 ...
- QT中添加工具条QToolBar
项目用的QT5.3,设计师中没有直接拖工具条的控件,那要怎么加工具条呢? 其实.ui文件是xml类型的文本文件,用uedit或记事本打开,找到之前有的工具条段落,复制粘贴一个,保存,再在vs中用设计师 ...
- spring cloud config svn仓库配置
之前快速入门了一下spring cloud config 但是仓库用的别人博客上的git仓库,公司用的是svn项目管理中心,下面这个自己配置的时候出现的错误 You need to configure ...
- PE格式文件的解析代码
#include "Global.h" ; //标志,用于表示是否为pe32+文件 ; //标志,用于表示读入的模式,若为0代表是内存读入,不为0,代表是文件打开,此时mode是文 ...
- js截取固定长度字符串,多余字符显示...
function cutstr(str, len) { var str_length = 0; var str_len = 0; str_cut = new String(); str_len = s ...
- Judy Beta Postmortem
设想和目标 1. 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 与Alpha阶段相同,我们的软件要解决的Julia程序的dubug功能.问题定义得比较清楚,具体分 ...
- Ubuntu17.04 安装搜狗中文输入法
http://blog.csdn.net/ydyang1126/article/details/76223656
- spring boot读取classpath下的json文件
import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resour ...