ssh-keygen -t rsa
指定密钥路径和输入口令之后,即在/home/msa/.ssh/中生成公钥和私钥:id_rsa id_rsa.pub(root账号下在/root/.ssh/中)
输入口令之后在CRT中登陆的时候需验证口令
如以下例子
[root@kangta-01 .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
06:25:cd:e3:b6:e7:13:76:3e:59:81:4f:77:43:bd:0a root@kangta-01
[root@kangta-01 .ssh]# ll
总计 12
-rw------- 1 root root 1743 11-28 23:47 id_rsa
-rw-r--r-- 1 root root 396 11-28 23:47 id_rsa.pub
-rw-r--r-- 1 root root 395 11-17 00:38 known_hosts
cat id_rsa.pub >> authorized_keys
至于为什么要生成这个文件,因为sshd_config里面写的就是这个。
然后chmod 400 authorized_keys,稍微保护一下。
在CRT上的终端可用sz id_rsa拉回本地,然后把服务器上的id_rsa和id_rsa.pub干掉
6)配置/etc/ssh/sshd_config
Protocol 2
ServerKeyBits 1024
PermitRootLogin no #禁止root登录而已,与本文无关,加上安全些
#以下三行没什么要改的,把默认的#注释去掉就行了
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
PermitEmptyPasswords no
7)重启sshd
/sbin/service sshd restart
8)转换证书格式
运行CRT,在tools下convert private key to openssh format 转换id_rsa为crt的ppk证书文件
9)配置CRT登录
在connection--SSH--publickey中,点击Browse,选择刚刚转换好的证书。
然后在connection-Data填写一下auto login username,例如我的是root
在session中填写服务器的IP地址,高兴的话可以save一下
转载于:https://blog.51cto.com/kangta/434929