环境:

AIX:192.168.1.235

Centos:192.168.1.121

一、修改配置文件

配置文件路径:/etc/ssh/sshd_config

修改如下内容:

#RSAAuthentication yes

#PubkeyAuthentication yes

#AuthorizedKeysFile      .ssh/authorized_keys

将其注释全部取消

二、生成密钥对

命令:ssh-keygen

在~/.ssh目录下生成了id_rsa           id_rsa.pub两个文件

其中id_rsa.pub即为本机公钥,需要将其复制到远程主机上

三、复制密钥

命令:scp id_rsa.pub  主机IP:~/.ssh/hostname.pub

在AIX上:scp id_rsa.pub 192.168.1.121:~/.ssh/aix.pub

在Centos上:scp id_rsa.pub 192.168.1.235:~/.ssh/centos.pub

四、将公钥追加进authorized_keys文件

在./ssh下创建一个文件authorized_keys

将对方公钥追加进该文件

AIX上:touch authorized_keys

cat centos.pub > authorized_keys

centos上:touch authorized_keys

cat aix.pub > authorized_keys