linux关闭登录密码,Linux 服务器使用密钥登录,关闭密码方式

首先登录服务器生成密钥对:

[jiucool@localhost ~]$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_jiucool -C "id_rsa for jiucool.org"

Generating public/private rsa key pair.

Created directory '/home/jiucool/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/jiucool/.ssh/id_rsa_jiucool.

Your public key has been saved in /home/jiucool/.ssh/id_rsa_jiucool.pub.

The key fingerprint is:

05:f8:a8:d8:c1:01:da:03:e0:0f:14:08:23:42:b5:5a id_rsa for jiucool

The key's randomart image is:

+--[ RSA 2048]----+

|%++o .. |

|*= o . . |

|.ooE . o . |

| =.o . .. |

| . + o S |

| . o |

| |

| |

| |

+-----------------+

进入目录,我们可以看到,已经生成了一对公钥也私钥

[jiucool@localhost ~]$ cd ./.ssh

[jiucool@localhost .ssh]$ ls

id_rsa_jiucool id_rsa_jiucool.pub

[jiucool@localhost .ssh]$

接着进行,对公钥进行改名:

[jiucool@localhost .ssh]$ mv id_rsa_jiucool.pub authorized_keys

chmod 600 ./*

然后 vi 修改 配置文件 ,将如下几项值进行修改

vi /etc/ssh/sshd_config

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile.ssh/authorized_keys

PasswordAuthentication no

重启ssh服务

sudo service sshd restart

我们将上述生成的私钥文件,导入到客户端SSH中就可以使用了。

版权声明:除特殊说明,文章均为博主 久酷 原创文章,转载请注明来源

标签:ssh分类:技术

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值