SSH 免密码登陆
1、master上生产公钥、私钥对
[root@XXX213 .ssh]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: b4:1a:63:57:80:d7:cd:cb:5c:ac:ab:b1:aa:7e:11:7d root@XXX The key's randomart image is: +--[ RSA 2048]----+ | ... o . | | . ... o o | | ....o + | | ..o. E | | + S. . . | | . =. . . | | . . + | | . o | | .oo.. | +-----------------+
2、将公钥发送给slave,并追加到/root/.ssh/authorized_keys 文件中
cat id_rsa.pub >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys #注意对其他组\其他用户不给任何读写权限
3、master能够实现免密码SSH登陆slave
[root@XXX213 .ssh]# ssh 192.168.10.214 -p 222 Last login: Thu Apr 6 12:43:16 2017 from 192.168.10.213 [root@XXX214 ~]#
注意:
1、master采用 生成ssh-genkey 使用的账号登陆slave。
2、master将自己的公钥追加到本地的authorized_keys 也能够实现自己登陆自己免密码。