Linux下通过 ssh-copy-id 无密码远程登录主机

来源:互联网 发布:用网络打电话的软件 编辑:程序博客网 时间:2024/06/04 18:17

在本地主机创建公钥和密钥

[root@controller ~]# ssh-keygen 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:c8:0c:24:84:2d:6d:fd:3c:2f:76:5a:70:e4:71:85:8f root@controllerThe key's randomart image is:+--[ RSA 2048]----+| =o..      o.    ||o +o.   o o      || o  .o o o o     ||     +=.o E .    ||      +=S        ||      o +        ||     . =         ||      .          ||                 |+-----------------+


 

将公钥远程复制至远程主机

[root@controller ~]# ssh-copy-id root@192.168.50.3root@192.168.50.3's password: Now try logging into the machine, with "ssh 'root@192.168.50.3'", and check in:  .ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.


登录远程主机

[root@controller ~]# ssh 192.168.50.3                              Last login: Tue Dec 24 09:34:32 2013 from controller[root@compute ~]# 

 

0 0