[Linux]通過ssh遠程登錄另一台電腦,無須每次都輸入密碼的辦法,通過copy-id


思路:

#step1:生成秘鑰 生成以后我這里保存在 /root/.ssh/id_rsa 記住這個位置 ssh-keygen #敲3次回車 #將秘鑰發送到另一台linux服務器 此過程會輸入免密登錄的linux用戶密碼 ssh-copy-id <username>@10.1.71.51 #執行ssh命令進行登錄 ssh <username>@10.1.71.51

具體操作:

step1:生成密鑰

ssh-keygen

 step2:將秘鑰發送到另一台linux服務器,

系統詢問是否繼續連接時,輸入yes

然后輸入root用戶的密碼

(ssh <username>@10.1.71.51)你使用的是哪個username,就輸入哪個username的登錄密碼)

wangju@wangju-HP-348-G4:~$ ssh-copy-id root@10.2.1.92 The authenticity of host '10.2.1.92 (10.2.1.92)' can't be established.
ECDSA key fingerprint is SHA256:Ar7EcI1o7lTpJNX7dD3FgDKyV7180t2iAGjXrjBlBGU. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@10.2.1.92's password:   Number of key(s) added: 1 Now try logging into the machine, with:   "ssh 'root@10.2.1.92'" and check to make sure that only the key(s) you wanted were added. 

step3:驗證配置結果:

再次執行 ssh  root@10.2.1.92,不需要再輸入密碼,即可連接成功 

wangju@wangju-HP-348-G4:~$ ssh root@10.2.1.92 Last login: Fri Jan 3 15:59:31 2020 from 10.1.71.32 [root@67 ~]# logout Connection to 10.2.1.92 closed.

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM