windows密钥登陆linux,windows 密钥登陆 linux

首先在服务器上生成密钥

[root@localhost support-files]# ssh-keygen -b 1024 -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:

b7:d1:01:3d:44:bc:9e:29:48:5b:e6:fd:b3:e0:bc:68 root@localhost.localdomain

[root@localhost support-files]# cd /root/.ssh/ 会生成2个 密钥

id_rsa id_rsa.pub

[root@localhost support-files]# vi /root/.ssh/authorized_keys 创建authorized_keys文件

[root@localhost support-files]# chmod 700 /root/.ssh/authorized_keys 赋予权限

[root@localhost support-files]# cat /root/.ssh/id_rsa.pub >>/root/.ssh/authorized_keys 将公钥拷贝到文件里

如果使用CRT进行远程链接将id_rsa 拷贝到windows里

如果使用的是putty 需要转换 具体步骤如下

使用putty key generator转换

151248906.jpg

将id_rsa 放进去 输入刚才生成的短语

151401376.jpg

点击保存

151528685.jpg

保存的文件要为xxx.ppk

[root@localhost ~]# vi /etc/ssh/sshd_config 打开ssh配置文件将以下三行注释

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication yes 改为 no 不允许密码登陆

注:winSCP 用的密钥文件也是.ppk

最后重启sshd大功告成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值