What you asking is almost the same as this.
If you don't want to copy key from gateway to local box, the work around is use Method 1 (bash alias) in that post(and below). ssh_config cannot do what you want. I have detail explanation there about the difference between alias and tunnel method, which include ssh_config ProxyCommand
.
Method 1
In ~/.bashrc
, add following line
alias ssh-test='ssh -t gateway ssh test@test'
In command prompt, just type following
ssh-test
What ssh -t gateway ssh test@test
do is almost the same as follow
local# ssh gateway
gateway# ssh test@test
Other than combining the two step in one, it skip opening a shell(csh, bash, etc) on gateway
, instead starting a ssh session to test
right after authentication.
You don't need ~/.ssh/config on local box BUT keep the one gateway for the test
(for key usage).
Adding ForwardAgent yes
to gatway .ssh/config
Host test
HostName 192.168.1.10
ForwardAgent yes
IdentityFile ~/keys/test
User test
Method 2
If you don't want to copy gateway key to local box, but permitted to install your local
ssh key into test@test
. Then you can use following
local ~/.ssh/config
Host gateway
User <gateway user>
HostName <gateway/IP>
Host test
User test
Hostname 192.168.1.10
Port 22
ProxyCommand ssh gateway nc %h %p