主机之间免密操作

文档来自:

https://cloud.tencent.com/developer/article/1039917

操作步骤

  1. 修改ssh配置

    # 每台linux主机修改配置文件/etc/ssh/sshd_config
    $ vi /etc/ssh/sshd_config
    
    #启用这三项配置,即去掉这三项的注释
    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile      .ssh/authorized_keys
    
    
  2. 生成公私钥

    #在源主机上执行 生成公私钥对
    $ ssh-keygen -t rsa -P ''
    
    
    # 查看生成的公私钥
    $ cd /root/.ssh/
    
    
    id_rsa: 私钥
    id_rsa.pub: 公钥
    
  3. 安装到目标主机

    $ scp /root/.ssh/id_rsa.pub [email protected]:/root/.ssh/;
    $ scp /root/.ssh/authorized_keys [email protected]:/root/.ssh/;
    
  4. 实验免密登录

    scp /root/.ssh/authorized_keys [email protected]:/root/.ssh/;
    ssh [email protected];
    

猜你喜欢

转载自blog.csdn.net/jinian2016/article/details/108022236