Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Created January 29, 2017 19:15
Show Gist options
  • Save adamsilverstein/0bb18538781309c4f42b981750d98ed4 to your computer and use it in GitHub Desktop.
Save adamsilverstein/0bb18538781309c4f42b981750d98ed4 to your computer and use it in GitHub Desktop.
In some environments it’s necessary to hop through 1 or even 2
gateways to reach the hosts.
In order to make this a little easier and also allow easy scp file
transfers here is a little guide for setting up ssh access.
Add the following to your ~/.ssh/config file
Host *
TCPKeepAlive yes
ServerAliveInterval 20
ServerAliveCountMax 10000
IdentityFile ~/.ssh/id_*
#ForwardAgent yes
#PermitLocalCommand yes
#LocalCommand ~/scripts/ssh_hostname.sh %h
controlmaster auto
controlpath /tmp/ssh-%r@%h:%p
SendEnv LANG LC_*
# Jump Host
Host jumphost
Hostname {jumphost ip}
IdentityFile ~/.ssh/id-jumphost-rsa
User {usernmame}
GSSAPIAuthentication no
TCPKeepAlive yes
ForwardAgent yes
# Hop to server 1
Host destination-1
Hostname {destination ip}
ProxyCommand ssh jumphost nc %h %p
User {username}
ForwardAgent no
# Hop to server 2
Host destination-2
Hostname {destination ip}
ProxyCommand ssh jumphost nc %h %p
User {username}
ForwardAgent no
If everything went well you can now connect to servers that require a connection thru the jumphost:
ssh destination-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment