Last active
April 24, 2023 15:21
-
-
Save ferry77/81280cc528ee6ca8b8e6ec77fe5f4b04 to your computer and use it in GitHub Desktop.
SSH connect to a server via JumpHost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# +-------+ +----------+ +-----------+ | |
# | 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