centos生成公钥私钥 securecrt通过公钥访问服务器 winscp通过公钥访问服务器
忙碌了一下午,一直到写博客现在。都在纠结阿里云服务器上配置公钥私钥,网上的说辞总是参差不齐,需要各个去综合,合理取舍。今天终于配置好了。
我就不说这种方式的重要性了,往往黑客都不需要你的登陆账户密码就能上你的服务器,多么可怕。比如【redis后门】自己百度哈。
直入主题:
[root@localhost .ssh]$ ssh-keygen -C"liyongdada" -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:
d2:5f:a7:c4:fa:66:1d:b8:64:49:31:03:e5:d8:3b:6eliyongdada
The key’s randomart image is:
±-[ RSA 2048]----+
| .o. |
| ++ |
| . o+ |
| . … |
| . S .*o. |
| . . ==+. |
| ooEo . |
| o+ . |
| o. |
±----------------+
[root@localhost .ssh]$ ls
id_rsa id_rsa.pub
执行完这个命令后,在/root/.ssh/目录有两个文件,黄色是私钥,绿色是公钥。还需要做一件事!
执行 cat id_rsa.pub >> authorized_keys 公钥内容输出到相应文件中
执行 rm -f id_rsa.pub 删除原来的公钥文件
执行 chmod 400 authorized_keys 将新建立的公钥文件属性设置为400
接下来配置conf文件:
执行 : vim /etc/ssh/sshd_config