OSWikiHK: 請協力 GPLv3 的中文翻譯工作。

Login via SSH without password

OSWikiHK,自由中文開源知識庫

產生金鑰

打「ssh-keygen -t rsa」產生一個新的 SSH key, 留意passphrase 應為空.

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/david/.ssh/id_rsa): 直接打Enter
Created directory '/home/david/.ssh'.
Enter passphrase (empty for no passphrase): 直接打Enter
Enter same passphrase again: 直接打Enter
Your identification has been saved in /home/david/.ssh/id_rsa.
Your public key has been saved in /home/david/.ssh/id_rsa.pub.
The key fingerprint is:
7f:a3:7c:37:54:08:2c:a8:37:0a:64:74:d9:7a:1f:0a david@mydomain.org

完成後,你的公鑰會放在你個人資料夾(Home Directory)的.ssh/id_rsa.pub中。

設定容許用公鑰登入

把自己的公鑰(~/.ssh/id_rsa.pub)附加在對方帳戶 (本例為jrandom@example.net) 中的檔案~/.ssh/authorized_keys中:

cat ~/.ssh/id_rsa.pub | ssh jrandom@example.net "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"

Debian用戶可以直接打 「ssh-copy-id jrandom@example.net」 取替以上長長的命令。

往後用ssh登入jrandom@example.net時就不需要輸入密碼。

ssh jrandom@example.net

相關文章

Personal tools
廣告橫額