1. 程式人生 > >3步實現ssh面密碼登錄

3步實現ssh面密碼登錄

been mach 自己的 warn cti copy continue emp private

1、上次本機的公鑰和私鑰

[root@vicweb ~]#ssh-keygen -t rsa
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: 24:ef:78:23:bf:51:2f:40:8b:b8:c8:f6:87:34:69:a4 [email protected] The keys randomart image is: +--[ RSA 2048]----+ | | | | | . o | | .. * . | | o... S . | | .E.=. o o . | | +o.oo = . . | | . .. .+ o . | | .. o. | +-----------------+

2、查看生產的文件(非必要操作,只是確認一下)

技術分享

3、把公鑰傳輸到指定機器,需要免密碼ssh登錄的機器,使用ssh-copy-id命令

[root@vicweb ~]#ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.10.90.102
The authenticity of host 10.10.90.102 (10.10.90.102) cant be established.
RSA key fingerprint is 05:90:7f:36:f2:c4:55:15:16:2d:27:54:30:67:c7:74.
Are you sure you want to 
continue connecting (yes/no)? yes Warning: Permanently added 10.10.90.102 (RSA) to the list of known hosts. root@10.10.90.102s password: Now try logging into the machine, with "ssh ‘[email protected]", and check in: .ssh/authorized_keys to make sure we havent added extra keys that you werent expecting.

check in到了對方的 authorized_keys文件,對方機器默認是沒有這個文件的,會自動生產一個這個文件,並把自己的公鑰寫到這個文件

4、測試登錄即可

[root@vicweb ~/.ssh]#ssh root@10.10.90.102
Last login: Thu Nov  9 09:24:35 2017 from 10.10.90.1

已實現自動登錄,不需要在輸入對方root的密碼。

3步實現ssh面密碼登錄