linux双机ssh免密登录实现

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tianxieeryang/article/details/81291090

环境:

      虚拟机:virtualBox

      linux系统:CentOS 7

      目标主机:A机、B机

操作:(以下顺序执行)

      A机:

  1.    ssh-keygen
  2.    进入root目录下的隐藏目录 .ssh 中     cd /root/.ssh     
  3.    scp id_rsa.pub [用户名]@****.****.****.****:/root    ( 用户名一般为root,IP地址可以用 ifconfig 命令查询 )

     B机:

     4.     touch authorized_keys      ( B机root目录下操作 )

     5.     chmod 600 authorized_keys      

     6.     cat id_rsa.pub >> authorized_keys

     7.     mv authorized_keys .ssh

以上 B 机对 A 机免密已做通。

   

     B 机:

  1.    ssh-keygen
  2.    进入root目录下的隐藏目录 .ssh 中     cd /root/.ssh     
  3.    scp id_rsa.pub [用户名]@****.****.****.****:/root    ( 用户名一般为root,IP地址可以用 ifconfig 命令查询 )

      A 机:

     4.     touch authorized_keys      ( A机root目录下操作 )

     5.     chmod 600 authorized_keys      

     6.     cat id_rsa.pub >> authorized_keys

     7.     mv authorized_keys .ssh

以上做通 A 机对 B 机免密。

=================================================================================

补充: ssh-keygen

          ssh-copy-id ip

猜你喜欢

转载自blog.csdn.net/tianxieeryang/article/details/81291090