SSH通过密钥登入.md

  • 在服务端生成密钥对:ssh-keygen -t rsa
[root@twx ~]# 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:
2d:34:ba:cc:f1:1e:8b:80:56:1e:6f:9d:37:8f:64:8d root@twx
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|        o        |
|       o o       |
|    o o S .      |
|   + = = o o     |
|  o o * = E .    |
| .   o o * +     |
|      . o . .    |
+-----------------+

生成的密钥对在/root/.ssh/文件夹下。

  • 将公钥文件输出到 一个特定的文件里(见步骤3里的文件名):cat id_rsa.pub > authorized_keys
-rw------- 1 root root  390 Jul 25 04:38 authorized_keys
-rw------- 1 root root 1675 Jul 25 04:37 id_rsa
-rw-r--r-- 1 root root  390 Jul 25 04:37 id_rsa.pub
  • 修改文件权限
chmod 600 authorized_keys
chmod 700 ~/.ssh
  • 修改ssh配置文件:vim /etc/ssh/sshd_config
    修改下面三行
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys  #(注意这个文件名)

退出保存

  • 重启ssh服务:service sshd restart

-------至此,服务端已经配置好了-------------------

putty

  1. 通过ftp工具把/root/.ssh/id_rsa文件下载到本地
  2. 打开puttygen.exe,点击Load,选择id_rsa,然后另存为putty格式的密钥
  3. 打开putty,点击SSH-Auth–选择加载private key
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值