优化.ssh / config

时间:2013-04-06 14:05:10

标签: optimization ssh config

我的.ssh / config:

Host *.gnu.org
  Compression yes 

Host bixeon
  User root
  ProxyCommand ssh newton nc -w 1 %h 22

Host freebsd.polarhome.com freebsd
  Port 715
  Protocol 2,1
  Hostname gate.polarhome.com

Host solaris.polarhome.com solaris
  Port 725
  Protocol 2,1
  Hostname gate.polarhome.com

Host openbsd.polarhome.com openbsd
  Port 735
  Protocol 2,1
  Hostname gate.polarhome.com

Host netbsd.polarhome.com netbsd
  Port 745  
  Protocol 2,1
  Hostname gate.polarhome.com

Host debian.polarhome.com debian
  Port 755
  Protocol 2,1
  Hostname gate.polarhome.com

Host alpha.polarhome.com alpha
  Port 765
  Protocol 2,1
  Hostname gate.polarhome.com

Host aix.polarhome.com aix
  Port 775
  Protocol 2,1
  Hostname gate.polarhome.com

Host hpux.polarhome.com hpux
  Port 785
  Protocol 2,1
  Hostname gate.polarhome.com

Host redhat.polarhome.com redhat
  Port 795
  Protocol 2,1
  Hostname gate.polarhome.com

Host ultrix.polarhome.com ultrix
  Port 805
  Protocol 2,1
  Hostname gate.polarhome.com

Host qnx.polarhome.com qnx
  Port 815
  Protocol 2,1
  Hostname gate.polarhome.com

Host irix.polarhome.com irix
  Port 825
  Protocol 2,1
  Hostname gate.polarhome.com

Host tru64.polarhome.com tru64
  Port 835
  Protocol 2,1
  Hostname gate.polarhome.com

Host openindiana.polarhome.com openindiana
  Port 845
  Protocol 2,1
  Hostname gate.polarhome.com

Host suse.polarhome.com suse
  Port 855
  Protocol 2,1
  Hostname gate.polarhome.com

Host openstep.polarhome.com openstep
  Port 865
  Protocol 2,1
  Hostname gate.polarhome.com

Host mandriva.polarhome.com mandriva
  Port 875
  Protocol 2,1
  Hostname gate.polarhome.com

Host ubuntu.polarhome.com ubuntu
  Port 885
  Protocol 2,1
  Hostname gate.polarhome.com

Host scosysv.polarhome.com scosysv
  Port 895
  Protocol 2,1
  Hostname gate.polarhome.com

Host unixware.polarhome.com unixware
  Port 905
  Protocol 2,1
  Hostname gate.polarhome.com

Host unknown1.polarhome.com unknown1
  Port 915
  Protocol 2,1
  Hostname gate.polarhome.com

Host centos.polarhome.com centos
  Port 925
  Protocol 2,1
  Hostname gate.polarhome.com

Host miros.polarhome.com miros
  Port 935
  Protocol 2,1
  Hostname gate.polarhome.com

Host hurd.polarhome.com hurd
  Port 945
  # Hurd fails with compression
  Compression no
  Protocol 2,1
  Hostname gate.polarhome.com

我觉得它可以写得更短。怎么样?

1 个答案:

答案 0 :(得分:3)

虽然我喜欢速记主机名方法,但我发现使用简写的“域名”来更好地控制适用的地方是值得的。此外,正如手册页所示,将主机特定的内容预先设置为覆盖最终所需的更一般的默认值。我添加了一个虚拟条目来显示我的意思(例如,虚拟必须通过不同的主机名或使用与默认值不同的用户或身份)。

Host freebsd.polarhome.com freebsd.ph
  Port 715

Host solaris.polarhome.com solaris.ph
  Port 725

...

Host dummy.polarhome.com dummy.ph
  Hostname dummy.polarhome.com
...

Host *.polarhome.com *.ph
  Protocol 2,1
  Hostname gate.polarhome.com