Skip to content

Instantly share code, notes, and snippets.

@ferry77
Last active April 24, 2023 15:21
Show Gist options
  • Save ferry77/81280cc528ee6ca8b8e6ec77fe5f4b04 to your computer and use it in GitHub Desktop.
Save ferry77/81280cc528ee6ca8b8e6ec77fe5f4b04 to your computer and use it in GitHub Desktop.
SSH connect to a server via JumpHost
# +-------+ +----------+ +-----------+
# | Laptop| <---> | Jumphost | <--> | FooServer |
# +-------+ +----------+ +-----------+
Host JumpHost
User ec2-user
HostName xx.xx.xx.01
# Add these 2 lines so we don't have to manually run 'ssh-add [key]'
UseKeychain yes
AddKeysToAgent yes
####################################
IdentityFile ~/.ssh/keys/key.pem
Host FooServer
User ec2-user
HostName xx.xx.xx.02
ProxyCommand ssh JUMPBOX nc %h %p
# ALTERNATE METHOD USING FORWARD AGENT, SSH JumpHost_1 then SSH [email protected]
Host JumpHost_1
User ec2-user
HostName xx.xx.xx.01
ForwardAgent yes
IdentityFile ~/.ssh/keys/key.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment