Centos下配置使用私钥文件登陆

来源:互联网 发布:精易模块源码 编辑:程序博客网 时间:2024/06/07 03:53

一、在Centos服务器上,生成秘钥对文件。

> ssh-keygen -t rsa

Enter file in which to save the key (/root/.ssh/id_rsa): authorized_key

Enter passphrase (empty for no passphrase): 回车

Enter same passphrase again: 回车

这时候,在用户的home的.ssh目录下,会生成 authorized_key (私钥) authorized_key.pub (公钥)文件。


二、修改SSH配置。

编辑/etc/ssh/sshd_config文件

Protocol 2

PasswordAuthentication no

PubkeyAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys.pub

修改完毕后,重启sshd服务


三、将一中生成的authorized_key文件,复制到本地。

使用:ssh -i authorized_key 服务器地址 登陆


0 0
原创粉丝点击