From http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/
http://www.unixwiz.net/techtips/ssh-agent-forwarding.html
https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-ssh-config/
part1 - command
in .ssh/config
:
Host test-1pauth-cassandra
Hostname 172.28.180.37
User ubuntu
ProxyCommand ssh nilseu.padilha@bastion.test.oneplatform.build -W %h:%p
ForwardAgent yes
command:
$ ssh -f -N -L 9042:172.28.180.37:9042 ubuntu@test-1pauth-cassandra
#http://www.unixwiz.net/techtips/ssh-agent-forwarding.html
#https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-ssh-config/
#https://www.digitalocean.com/community/tutorials/how-to-configure-custom-connection-options-for-your-ssh-client
Host test-bastion
HostName bastion.test.oneplatform.build
User nilseu.padilha
Host test-gatling
Hostname 172.28.198.57
User ec2-user
ProxyCommand ssh nilseu.padilha@bastion.test.oneplatform.build nc %h %p
Host test-*
PubkeyAuthentication yes
ForwardAgent yes
Host *
ServerAliveInterval 30
ServerAliveCountMax 120
PubkeyAuthentication yes
ForwardAgent no
eval `ssh-agent`
ssh-add ~/.ssh/KP_developer.pem
ssh-add ~/.ssh/KP_infrastructure.pem
ssh-add ~/.ssh/main-access.pem
# ssh -A nilseu.padilha@bastion.dev.oneplatform.build -i /c/dev/keys/tr_key_rsa
echo $SSH_AUTH_SOCK
echo $SSH_AGENT_PID
ssh-agent -k
source: http://superuser.com/questions/456438/how-do-i-scp-a-file-through-an-intermediate-server
This has already been answered best here.
To summarize: put the following in ~/.ssh/config
Host target.machine
User targetuser
HostName target.machine
ProxyCommand ssh proxyuser@proxy.machine nc %h %p 2> /dev/null
and then simply scp to target.machine any time you want to proxy via proxy.machine!
Also works for ssh, so will save you time ssh-ing to the target machine too.
Credit should go to user24925 who answered this in 2011.
$ ssh -f -N -L 9906:127.0.0.1:3306 coolio@database.example.com
# -f puts ssh in background
# -N makes it not execute a remote command
# contents of $HOME/.ssh/config
Host tunnel
HostName database.example.com
IdentityFile ~/.ssh/coolio.example.key
LocalForward 9906 127.0.0.1:3306
User coolio
$ ssh -f -N tunnel
# contents of $HOME/.ssh/config
Host devHost github-project1
User git
HostName github.com
IdentityFile ~/.ssh/github.project1.key</p>
Host github-org
User git
HostName github.com
IdentityFile ~/.ssh/github.org.key</p>
Host github.com
User git
IdentityFile ~/.ssh/github.key
#usage
$ git clone git@github-org:orgname/some_repository.git
# contents of $HOME/.ssh/config
Host dev
HostName dev.example.com
Port 22000
User fooey
# private public
Host dev
HostName dev.example.com
Port 22000
User fooey