Linux SSH免密登录

目录结构:

[root@localhost .ssh]# tree -a
.
├── authorized_keys
├── id_dsa
├── id_dsa.pub
├── id_rsa
├── id_rsa_2048_9417.pub
├── id_rsa.pub
└── known_hosts

本机自实现SSH免密码登录

步骤一:生成公私钥对

ssh-keygen

步骤二:查看是否有"authorized_keys"文件,如果有,直接将公钥追加到"authorized_keys"文件中,如果没有,创建"authorized_keys"文件,并修改权限为"600"

cd /root/.ssh
touch authorized_keys
chmod 600 authorized_keys

步骤三:将公钥追加到"authorized_keys"中

 cat id_rsa.pub >> authorized_keys 

两台主机实现SSH免密码登录(单向登录只需配置一台即可)

步骤一:两台主机分别生成公私钥对

ssh-keygen

步骤二:使用scp命令,将本机的公钥发给对方

cd /root/.ssh
scp -p ids_rsa.pub root@***:/root/

步骤三:将对方的公钥追加到"authorized_keys"中

touch authorized_keys
cat /root/id_rsa.pub >> authorized_keys

参考:

https://blog.csdn.net/mmd0308/article/details/73825953
 

 

 

你可能感兴趣的:(linux)