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 p_w_picpath 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":

输入上面设置的密码即可