美文网首页
centos服务器配置密钥登录

centos服务器配置密钥登录

作者: A浓眉小眼A | 来源:发表于2021-02-22 08:59 被阅读0次

    1、生成密钥文件

    ssh-keygen -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.

    chmod -R 700 /root/.ssh/    #设置权限,仅当前用户可以读写

    下载该文件下的id_rsa私钥文件

    2、设置ssh只能密钥登录

    vim /etc/ssh/sshd_config  #编辑ssh配置文件

    PasswordAuthentication no  #关闭密码登录

    systemctl restart sshd  #重启服务

    注意:一定要在确认密钥文件可以使用后再关闭密码登录

    相关文章

      网友评论

          本文标题:centos服务器配置密钥登录

          本文链接:https://www.haomeiwen.com/subject/mvkhfltx.html