主机A:172.28.9.208(oracle/oracle123)
主机B:172.28.6.190 (oracle/oracle)
需要配置主机A无密码登录主机A,主机B
先确保所有主机的防火墙处于关闭状态。
在主机A上执行如下:
1. $cd ~/.ssh
2. $ssh-keygen -t rsa --------------------然后一直按回车键,就会按照默认的选项将生成的密钥保存在.ssh/id_rsa文件中。
Generating public/private rsa key pair. Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/oracle/.ssh/id_rsa. Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub. The key fingerprint is: a5:5c:80:81:6c:2d:8c:0e:89:11:0d:c8:9a:13:b9:bc oracle@idc-sparc |
3. $cp id_rsa.pub authorized_keys 这步完成后,正常情况下就可以无密码登录本机了,即ssh localhost,无需输入密码。
4. $scp authorized_keys oracle@172.28.6.190:/home/oracle/.ssh ------把刚刚产生的authorized_keys文件拷一份到主机B上.
进入主机B的.ssh目录,改变authorized_keys文件的许可权限
$chmod 600 authorized_keys