1、安裝openssh、openssh-server
2、啟動sshd:service sshd start
3、設定開機自動啟動sshd:chkconfig --level 35 sshd on
4、建立私鑰公鑰:ssh-keygen -t rsa
[user@centos64 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wspjing/.ssh/id_rsa): //此處直接按回車即可
Enter passphrase (empty for no passphrase): //設定私鑰使用密碼,要求4個字元以上
Enter same passphrase again:
Your identification has been saved in /home/wspjing/.ssh/id_rsa.
Your public key has been saved in /home/wspjing/.ssh/id_rsa.pub.
The key fingerprint is:
fa:a2:fe:4e:8b:ab:dc:cb:73:ab:6f:42:a7:4a:94:52 user@centos64
The key's randomart image is:
+--[ RSA 2048]----+
| |
| E |
| . . |
|. o S |
| o . .. |
| .. oo |
| o o+o+o |
| ++X&*o. |
+-----------------+
5、設定公鑰
[user@centos64 ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[user@centos64 ~]$ rm -f ~/.ssh/id_rsa.pub
6、将私鑰 id_rsa 下載下傳到windows系統裡。
7、用puttygen轉換id_rsa,“load”--“All files”--找到“id_rsa”檔案,打開,輸入上面的密碼,會提示“Successfully imported...“,“确定”--“Save private key”,此過程中的其他選項均為預設。
8、打開putty軟體,左邊“Connection”--“Data”,右邊"Auto-login username“後面輸入私鑰對應的使用者名;左邊“Connection”--"SSH"--"Auth“,右邊"Browse...",找到私鑰檔案,擴充名為"ppk"的檔案;左邊"Session",右邊Host Name下輸入伺服器IP位址,"Save Sessions"下輸入要儲存的快捷名,如"auto",再點選“Save”。
9、點選"open",提示
Using username "username".
Authenticating with public key "imported-openssh-key"
Passphrase for key "imported-openssh-key":
輸入上面設定的密碼即可
本文轉自yzy121403725 51CTO部落格,原文連結:http://blog.51cto.com/lookingdream/1600333,如需轉載請自行聯系原作者