美文网首页
linux中免密登录@2024-03-01

linux中免密登录@2024-03-01

作者: dataHunter | 来源:发表于2024-02-29 17:20 被阅读0次
    # 各机器创建秘钥
    ssh-keygen -t rsa
    
    # 从各个机器汇集公钥到ip1
    scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/2.id.rsa.pub
    scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/3.id.rsa.pub
    scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/4.id.rsa.pub
    scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/5.id.rsa.pub
    scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/6.id.rsa.pub
    
    # 在ip1里生成秘钥认证文件
    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    cat ~/.ssh/2.id.rsa.pub >> ~/.ssh/authorized_keys
    cat ~/.ssh/3.id.rsa.pub >> ~/.ssh/authorized_keys
    cat ~/.ssh/4.id.rsa.pub >> ~/.ssh/authorized_keys
    cat ~/.ssh/5.id.rsa.pub >> ~/.ssh/authorized_keys
    cat ~/.ssh/6.id.rsa.pub >> ~/.ssh/authorized_keys
    
    # 向集群机器分发认证文件
    scp ~/.ssh/authorized_keys root@ip2:~/.ssh/
    scp ~/.ssh/authorized_keys root@ip3:~/.ssh/
    scp ~/.ssh/authorized_keys root@ip4:~/.ssh/
    scp ~/.ssh/authorized_keys root@ip5:~/.ssh/
    scp ~/.ssh/authorized_keys root@ip6:~/.ssh/
    
    

    相关文章

      网友评论

          本文标题:linux中免密登录@2024-03-01

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