美文网首页
2018-11-17ssh登录远程服务器

2018-11-17ssh登录远程服务器

作者: 大年小爱 | 来源:发表于2018-11-18 14:02 被阅读0次

    每天都要登录跳板机,再登录服务器,不停的输入用户名,ip和密码,好烦啊。

    想想办法:

    1,输入命令,在本机生成一对儿秘钥(公钥私钥)。:这一步我是之前做好的,所以没有再做,命令百度一下有很多的。

    2.登录到跳板机上,打开cat ~/.ssh/authorized_keys ,里边放入自己的私钥。

    3. 在本机新建或者保存以下内容到~/.ssh/config

    Host *

      ControlMaster auto

      ControlPath ~/.ssh/ctlsock_%h_%p_%r

      ControlPersist yes

      ServerAliveInterval 30

      ServerAliveCountMax 999999

    4. 断开,重新登录跳板机。发现不需要密码了。

    5.  把ssh username@ip 做一个软链,存到.profile(vi .profile)

    内容:alias jump='ssh zhengxin@106.75.22.248'

    6. 在本机执行  . .profile

    7. 所有都关了,重新打开,输入jump跳到跳板机。

    8. 从跳板机到服务器。先在跳板机上生成一对儿秘钥

    ssh-keygen -t rsa -b 2048

    9. 在跳板机vi ~/.ssh/config记录host。

    内容:

    Host *

      User zhengxin1

    然后登录的时候,输入ssh ip就可以了

    相关文章

      网友评论

          本文标题:2018-11-17ssh登录远程服务器

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