2007年5月11日

設定ssh自動登入

一般ssh都必須要輸入密碼才可以登入遠端系統主機,如果因為某些理由不想輸入密碼的話,可以利用交換密鑰來達到認證的方式:
假設現在有
  • 遠端伺服器Server A
  • 近端伺服器Server B
使用者想從ServerB連線到ServerA伺服器而不使用密碼,則可以在ServerB執行以下指令:
ssh-keygen -t rsa (指定產生的密鑰類型)
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wales/.ssh/id_rsa): <<金鑰放置的地點>>
Created directory '/home/wales/.ssh'.
Enter passphrase (empty for no passphrase): <<輸入金鑰密碼,請留空白>>
Enter same passphrase again: <<再輸入一次密碼>>
Your identification has been saved in /home/wales/.ssh/id_rsa.
Your public key has been saved in /home/wales/.ssh/id_rsa.pub.
The key fingerprint is:xx:xx:xx:xx:xx:xx
之後在/home/wales/.ssh/會產生兩個檔案id_rsaid_rsa.pub
id_rsa.pub記載著公鑰的資訊,請將此公鑰發佈到ServerA,並儲存到/home/wales/.ssh/authorized_keys
完成設定之後,回到ServerB並執行ssh wales@serverA
The authenticity of host 'serverA' can't be established.
RSA key fingerprint is :xx:xx:xx:xx:xx:xx
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'serverA' (RSA) to the list of known hosts.
wales@serverA's password:
輸入這次密碼後 下次就不會再詢問了。
附註:在/etc/ssh/sshd_conf 底下的StrictModes要改為no,並重開sshd服務

精選文章

利用Selenium IDE進行UI測試

安裝與執行 Selenium IDE是Firefox的一個plugin,用來做UI的自動測試:下載網址為http://docs.seleniumhq.org/download/ 安裝後,點一下firefox 的工具 -> Selenium IDE ,就會...