Linux SSH登录互信配置(2)
导读:Linux,600和644 **。 .ssh目录 权限必须是 700 选项: -t rsa|dsa 默认是 rsa 格式。 接着可以查看生成的公钥和私钥文件: [root@MYDB01 ~]# cd /root/.ssh[root@MYDB01 .ssh]# pwd/ro
Linux
600和644**。
.ssh目录权限必须是700
选项:
-t rsa|dsa默认是rsa格式。
接着可以查看生成的公钥和私钥文件:
[root@MYDB01 ~]# cd /root/.ssh
[root@MYDB01 .ssh]# pwd
/root/.ssh
[root@MYDB01 .ssh]# ll -sh
总用量 12K
4.0K -rw------- 1 root root 1.7K 2月 14 16:17 id_rsa
4.0K -rw-r--r-- 1 root root 393 2月 14 16:17 id_rsa.pub
[root@MYDB01 .ssh]#
4.2将自己的公钥文件发送给对方
# 命令格式:
ssh-copy-id [-i [identity_file]] [user@]machine
这个命令的作用是:将id_rsa.pub文件内容传输至对方的.ssh目录中,生成文件名为authorized_keys文件,并且会设置远程主机用户目录的**.ssh和.ssh/authorized_keys**权限。
# 在MYDB01上执行以下操作:
[root@MYDB01 .ssh]# ssh-copy-id 192.168.250.194
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.250.194's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.250.194'"
and check to make sure that only the key(s) you wanted were added.
[root@MYDB01 .ssh]#
这里在MYDB02主机上查看:
[root@MYDB02 ~]# cd /root/.ssh
[root@MYDB02 .ssh]# ll
总用量 12
-rw------- 1 root root 393 2月 14 16:41 authorized_keys
-rw------- 1 root root 1679 2月 14 16:20 id_rsa
-rw-r--r-- 1 root root 393 2月 14 16:20 id_rsa.pub
[root@MYDB02 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtQ+pBp1T9fHAkrifEShaOAfBJFT+HdljR8mBxl7wZ1a91g3Zuzu35gJKsUjD+NqP9JcdyKapE309SHPvosvsJjLfccF4PaEZAgqHryu+S3cBn8zqA6fm62hsx/qI4I80PV0btcqfwphsD+5+vgkDJWAsUGQtqZdmMClAIy5gs0He0K2jpciKHvxWWClB3+dTJ0e9yIuIkV7lM+jqVIqYFJD0bRyy0zgNsY5/cLYFllM42TQDos93hVdqGXOHREpWo01KX2Jd8MKj4yNeiqgnj2mDtiNFWOUSkAbHpcKInuUOErJMqkV7MP0er5UKY/NemDzuORr2RxYqSTWaz/T7N root@MYDB01
[root@MYDB02 .ssh]#
上面的操作只是单方面信任,主机MYDB01登录主机MYDB02不需输入密码,反过来不行,所以还需下面操作:
# 在主机MYDB02上将其钥复制到主机MYDB01上:
[root@MYDB02 .ssh]# ssh-copy-id 192.168.250.193
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.250.193 (192.168.250.193)' can't be established.
ECDSA key fingerprint is SHA256:vThEoRhUOECeD5jhE+m8TZA2+6OoElIoNOQ3XqtopZw.
ECDSA key fingerprint is MD5:97:40:b2:35:6e:07:5a:61:1f:73:f1:b2:6e:54:5b:7d.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.250.193's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.250.193'"
and check to make sure that only the key(s) you wanted were added.
[root@MYDB02 .ssh]#
相关阅读
-
windows商店点了安装没反应 windows11商店打不开解决教程
今天小编介绍windows11商店打不开解决教程方面的介绍,关于windows商店点了安装没反应 windows11商店打不开解决教程,接下来IT袋带大家一起了解。 win11系统的商店更新了很多全新的应用等待用户
-
win11系统镜像下载官网 下载win11镜像的地址介绍
文章摘要:下载win11镜像的地址介绍的介绍,关于win11系统镜像下载官网 下载win11镜像的地址介绍,具体详情如下: 此前在网络上流传了一个win11的镜像版本系统,使用镜像安装win11可以有效避
-
win10恢复系统方法教程 电脑开不了机解决的方法
如果想了解win10恢复系统方法教程和电脑开不了机解决的方法的话题,一起来看看吧! win10系统软件实际上是一个更好的智能控制系统,强大的尖端技术可以确保系统软件在各种环境中的连续操
-
玩游戏选择win10哪个版本 win10玩游戏装哪个版本推荐介绍
为关注IT袋网的网友们详解win10玩游戏装哪个版本推荐介绍的电脑方面的小经验,关于玩游戏选择win10哪个版本 win10玩游戏装哪个版本推荐介绍,接下来一起来看看吧。 玩游戏是现在每个小伙伴


