美文网首页
linux 密钥登陆

linux 密钥登陆

作者: 醉眼看人间_个个都温柔 | 来源:发表于2019-07-22 22:05 被阅读0次
    用root登陆执行以下命令
    cd /root/.ssh/
    rm -f id_rsa    删除原密钥
    ssh-keygen -m PEM -t rsa -b 4096  三次回车生成密钥(强制生成RSA格式密钥)
    cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys                                   在服务器上安装公钥
    cd /root/.ssh/;chmod 600 authorized_keys;chmod 700 ~/.ssh                                   修改文件权限
    service sshd restart   重启ssh
    
    sz /root/.ssh/id_rsa  下载密钥
    
    
    
    sed -i -e 's/#PubkeyAuthentication/PubkeyAuthentication/g' /etc/ssh/sshd_config 打开密钥登陆 
    
    
    sz /root/.ssh/id_rsa  下载密钥文件用于CRT登陆
    
    
    验证密钥可以登陆后取消密码登陆
    sed -i -e 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config   取消密码登陆
    
    

    相关文章

      网友评论

          本文标题:linux 密钥登陆

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