ubuntu root下的無密碼登錄

之前都是兩臺機器在普通用戶之間無密碼登錄,今天兩臺機器都是root下配置無密碼登錄,方法很簡單,寫下過程: dom

注:以root下節點c01無密碼登錄c02爲例 ssh

1.c01執行:ssh-keygen -t rsa,按y,enter,enter ide

root@c01:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
12:68:51:41:7a:72:65:ba:e7:d3:ab:d6:0f:3b:d4:f6 root@cloud
The key's randomart image is:
+--[ RSA 2048]----+
|    .o+.o        |
|     + +         |
|    = =          |
|   . + o         |
|      o S  .     |
|       + .. o    |
|        ooo. .   |
|        ..o+  E  |
|       ...oo.    |
+-----------------+
加密

2.在c02上爲root添加密碼:passwd root,輸入你的密碼 spa

root@c02:~/.ssh# passwd root
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully .net

3.把c01公鑰傳至c02,並命名authorized_keys,執行:scp /root/.ssh/id_rsa.pub root@172.18.48.5:/root/.ssh/authorized_keys,輸入你的root密碼,發送成功 server

4.co1上執行:ssh 172.18.48.5,就能夠在root下直接c01無密碼登錄c02了 get

相關文章
相關標籤/搜索