ssh别名登录,非常适合从跳板机登录其他主机

  一般连主机会是这样的:

    ssh admin@IP 

  端口变了的话还要加上端口号

    ssh admin@IP -p 10022 

  可以用ssh别名简化这个操作:

    vim .ssh/config

    想要全局生效的话,写入/etc/ssh/ssh_config 中即可。

host proxy
HostName 112.xx.xx.x
User admin
Port 10022

  把config 权限改成600,他人不能访问

    chmod 600 .ssh/config

  之后便能通过ssh别名登录:

    ssh proxy

  再这之后还可以通关ssh-copy-id来复制密钥实现免登录,这里复述了。


2014-10-14 10:15:04

发现一篇好文

http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

 特别适合多key的情况,比如你有多个github ,gitlab,csdn的git ,这个时候ssh-keygen -f filename 生成多个key ,每个对应一个,在config 里面写上 

host git.aca.com

  identityfile ~/.ssh/gitlab.key
  user git 

  

这样,就非常方便了。

原文地址:https://www.cnblogs.com/gqdw/p/3896205.html