zoukankan      html  css  js  c++  java
  • linux设置秘钥登录

    1、在linux服务器生成公钥和私钥

    [root@localhost .ssh]# ssh-keygen 
    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.
    The key fingerprint is:
    02:54:da:3a:4e:d4:21:44:9c:f6:47:22:db:50:71:77 root@localhost.localdomain
    The key's randomart image is:
    +--[ RSA 2048]----+
    |   +=+=.. . E    |
    |   .*=.o.. .     |
    |   .+*oo         |
    |   ..oo .        |
    |    + ..S        |
    |   o . .         |
    |    .            |
    |                 |
    |                 |
    +-----------------+

    2、配置文件开启秘钥登录

    cat /etc/ssh/sshd_config

    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile      .ssh/authorized_keys

      systemctl restart sshd

    3、创建认证文件

    touch .ssh/authorized_keys
    chmod 700 .ssh/authorized_keys
    cat .ssh/id_rsa.pub >> .ssh/authorized_keys

    4、win客户端秘钥登录

    将.ssh/id_rsa下载到win客户端

    通过Xshell等工具将秘钥导入

     

    选择导入秘钥登录即可

     5、linux客户端秘钥登录

    将公钥复制到linux客户端

    cd .ssh
    ssh-copy-id -i id_rsa.pub root@192.168.50.131
    ssh 192.168.50.131
  • 相关阅读:
    NFS 服务器实验
    ssh服务实验
    dhcp服务实验
    邮件服务器
    搭建 DNS 服务器
    搭建 web 服务器
    Feign下的数据传递
    基于Spring Cloud Feign的Mock工具
    Git 使用注意事项
    基于redisson的延迟队列
  • 原文地址:https://www.cnblogs.com/xue0123/p/15035826.html
Copyright © 2011-2022 走看看