1、进入sshd_config(/etc/ssh/sshd_config)
#ServerKeyBits 768
ServerKeyBits 1024 修改加密强度为1024bit
#PasswordAuthentication yes
PasswordAuthenticatino no 不允许密码方式登陆
#PermitEmptyPasswords on
PermitEmptyPasswords no 禁止空密码登陆
2、修改hosts.deny(/etc/hosts.deny)文件,禁止所有的SSH连接。
在hosts.deny文件末尾加上sshd:ALL
3、修改hosts.allow(/etc/hosts.allow)文件,加上允许进行SSH连接的IP地址或IP地址段。
在hosts.allow文件末尾加上sshd:IP地址或IP地址段
4、重启SSH服务
service sshd restart
5、创建公钥与私钥文件
[root@CentOS~]ssh-keygen -t rsa 创建公钥与私钥
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): ← 钥匙的文件名,这里保持默认直接回车
Created directory '/root/.ssh'
Enter passphrase (empty for no passphrase): ← 输入口令
Enter same passphrase again: ← 再次输入口令
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
tf:rs:e3:7s:28:59:5s:93:fe:33:84:01:cj:65:3b:8e root@CentOS~
[root@CentOS ~]# cd ~/.ssh ← 进入用户SSH配置文件的目录
[root@CentOS ~]# ls -l ← 列出文件
total 16
-rw------- 1 root root 951 Sep 4 19:22 id_rsa ← 确认私钥已被建立
-rw-r--r-- 1 root root 241 Sep 4 19:22 id_rsa.pub ← 确认公钥已被建立
[root@CentOS ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ← 公钥内容输出到相应文件中
[root@CentOS ~]# rm -f ~/.ssh/id_rsa.pub ← 删除原来的公钥文件
[root@CentOS ~]# chmod 400 ~/.ssh/authorized_keys ← 将新建立的公钥文件属性设置为400
6、导出id_rsa文件
7、使用PuTTY工具组里的PuTTYGen来转换私钥,打开PuTTYGen,选择“载入”,选择刚才的“id_rsa”文件(选择文件的时候,文件类型改为“所有文件(*.*)”),输入刚才创建公钥与私钥时候的密码,便可以转缼成功,并选择“保存私钥”。
8、在用PuTTY登陆Linux系统的时候,在下面的“SSH”-“认证”里,在“认证私钥文件处”选择刚才转换的私钥文件即可进行登陆。
pure-ftp之pur
和谐。



