Linux实现免密码登录

参考链接:http://www.jb51.net/article/94599.htm
ssh @

1.帮助命令:man ssh-keygen
2.生成秘钥文件命令:ssh-keygen -t rsa
 默认回车
3.用户目录下查看文件,目录路径:~/.ssh/

ssh公钥生效需满足至少下面两个条件:
1) .ssh目录的权限必须是700 
2) .ssh/authorized_keys文件权限必须是600

4.秘钥拷贝方式(四选一即可):

1.>适合两台机器相同用户名的免密登录

ssh-copy-id -i ~/.ssh/id_rsa.pub 
示例: ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.50.103

2.>可以用在不同用户间免密登录

scp -p ~/.ssh/id_rsa.pub root@:/root/.ssh/authorized_keys
示例:scp -p ~/.ssh/id_rsa.pub [email protected]:/root/.ssh/authorized_keys

3.>拆分上面的操作,分两步实施

scp ~/.ssh/id_rsa.pub root@:pub_key //将文件拷贝至远程服务器
cat ~/pub_key >>~/.ssh/authorized_keys //将内容追加到authorized_keys文件中, 不过要登录远程服务器来执行这条命令

4.>手动复制

手动复制id_rsa.pub文件内容到目标端主机的authorized_keys文件.
cat id_rsa.pub >> .ssh/authorized_keys

你可能感兴趣的:(Linux实现免密码登录)