如何免用密碼登入ssh伺服器?
雖然說應該已經很老生常談了, 但是為了怕我自己忘掉. 註記一下.
我是參考這篇文章的:
Getting started with SSH - Kimmo Suominen
首先, 你需要確定已經在兩台機器上都已經安裝了ssh, 而且被登入的那台已經執行sshd, 可以被登入了.
接下來, 在local執行以下指令產生dsa key:
# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jouston/.ssh/id_rsa): [RETURN]
Enter passphrase (empty for no passphrase): [RETURN]
Enter same passphrase again: [RETURN]
Your identification has been saved in /home/jouston/.ssh/id_rsa.
Your public key has been saved in /home/jouston/.ssh/id_rsa.pub.
The key fingerprint is:
aa:aa:aa:......:aa jouston@jouston.no-ip.com
基本上只需要連續按幾次[RETURN](就是鍵盤的[ENTER]鍵)
好了, 我們做到這一步已經弄到key了. 接下來需要把dsa.pub複製到遠端的伺服器:
# scp ~/.ssh/dsa.pub 10.1.1.1:.ssh/authorized_keys
搞定收工.
另外, 如果有多台機器要這樣免密碼登入的話, 你可以把後來的key在遠端機器那裡這麼作:
# cat dsa.pub >> authorized_keys
直接附加上去就可以了
我是參考這篇文章的:
Getting started with SSH - Kimmo Suominen
首先, 你需要確定已經在兩台機器上都已經安裝了ssh, 而且被登入的那台已經執行sshd, 可以被登入了.
接下來, 在local執行以下指令產生dsa key:
# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jouston/.ssh/id_rsa): [RETURN]
Enter passphrase (empty for no passphrase): [RETURN]
Enter same passphrase again: [RETURN]
Your identification has been saved in /home/jouston/.ssh/id_rsa.
Your public key has been saved in /home/jouston/.ssh/id_rsa.pub.
The key fingerprint is:
aa:aa:aa:......:aa jouston@jouston.no-ip.com
基本上只需要連續按幾次[RETURN](就是鍵盤的[ENTER]鍵)
好了, 我們做到這一步已經弄到key了. 接下來需要把dsa.pub複製到遠端的伺服器:
# scp ~/.ssh/dsa.pub 10.1.1.1:.ssh/authorized_keys
搞定收工.
另外, 如果有多台機器要這樣免密碼登入的話, 你可以把後來的key在遠端機器那裡這麼作:
# cat dsa.pub >> authorized_keys
直接附加上去就可以了
留言
張貼留言