美文网首页
ssh免密别名登录

ssh免密别名登录

作者: ntjsz | 来源:发表于2017-12-20 21:11 被阅读0次

    免密登录

    1. 在本地,生成rsa公私密钥对
    2. 将公钥文件scp到远程服务器
    xx@xxx:~# ssh-keygen
    xx@xxx:~# scp .ssh/id_rsa.pub yy@yyy:~
    
    1. 在远程服务器,将公钥文件append到~/.ssh/authorzied_keys内
    yy@yyy:~# cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
    

    别名登录

    1. 在本地的~/.ssh/config文件中加入如下内容
    Host zzz
        HostName aa.bb.cc.dd
        Port 22
        User root
        IdentityFile  ~/.ssh/id_rsa
    

    上述参数含义

    • Host 别名
    • HostName 远程服务器的主机域名或ip
    • Port 远程服务器使用的ssh端口号,默认22
    • User 用户名
    • IdentityFile 上述免密登录步骤中生成的私钥文件路径 默认~/.ssh/id_rsa
    1. 使用别名即可免密登录
    xx@xxx:~# ssh zzz
    

    相关文章

      网友评论

          本文标题:ssh免密别名登录

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