Linux免密码登陆

在服务器运维过程当中,有时为了方便执行脚本,会设置免密码登陆。node

固然若是这个主机被攻破,那么其余主机也就乖乖投降了。git

完成免密登陆,主要使用两个命令:服务器

第一个:生成公钥运维

ssh-keygen

Generating public/private key pair.
Enter file in which to save the key (/ceph-admin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /ceph-admin/.ssh/id_rsa.
Your public key has been saved in /ceph-admin/.ssh/id_rsa.pub.

tips:使用git时候,根据后台设置,有些操做须要公钥,此时也须要生成公钥。ssh

默认的Windows的公钥地址是“C:\Users\[SomeOne]\.ssh\id_rsa.pub",默认的Linux公钥地址在“~/.ssh/id_rsa.pub”ide

第二个:把公钥复制到其余服务器spa

ssh-copy-id root@node1

其中node1是目标主机,能够是ip地址,也能够是域名。code

相关文章
相关标签/搜索