I tested this setup with Linux origin machine - everything is the same - only the first hop can use keys from origin machine.
Initial problem
I'm trying to set up SSH agent forwarding with multiple hops. My local machine is Windows, with putty and pageant, all Linux machines are Debian 7.
The problem is that my private keys, originating from windows, work only on the first hop. Private key added on any the first machine works everywhere.
First hop machine is called 'vpn1', second 'www1'. 'vpn1' is connected to internet and to intranet(10.1.0.1). 'www1' is connected only to intranet(10.1.0.10). 'vpn1' adds key([email protected]) using 'ssh-add', this key shows in pageant.
Debugging
I see all 3 keys in ssh-add -L
:
ssh-rsa [pubkey-1] [email protected] //This is github key originating from Windows
ssh-rsa [pubkey-2] [email protected] //This is SSH key originating from Windows
ssh-rsa [pubkey-3] [email protected] //This is SSH key originating from 'vpn1'
When I try to ssh -v -T [email protected]
from 'vpn1'
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: [email protected]
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
When I try to ssh -v -T [email protected]
from 'www1'
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: [email protected]
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: [email protected]
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: [email protected]
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /home/enbyted/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/enbyted/.ssh/id_dsa
debug1: Trying private key: /home/enbyted/.ssh/id_ecdsa
debug1: Next authentication method: password
The same goes with ssh to hosts that accept only '[email protected]' key. But I can SSH with as many hops as I like with '[email protected]'. Of course, the same goes for git commands.
Configurations
My ~/.ssh/config
(same on all servers):
Host 10.1.0.*
ForwardAgent yes
Host *
ForwardAgent no
My /etc/ssh/sshd_config
(without comments, same on all servers):
Port <custom-port>
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
Questions
- So, why is that?
- What am I doing wrong?
Also it's really strange, that on 'www1' github offers two auth methods - password and publickey ... I'm sure that 'www1' SSHing to github.com is connecting to the same server as 'vpn1'.
Update #1: network setup on image
Please note, that image is from article, but pretty much shows my setup.
So, I have 2 keys on my home PC, and one key on ruapehu (vpn1).
When I SSH to ruapehu from the home PC I can use all three keys just fine. But when I do another ssh from ruapehu (vpn1) to aoraki (www1) I can use only the key from ruapehu.
And when I ssh from aoraki (www1) to any hosts below with any amount of hops only key from ruapehu works.
It doesn't if home PC is Windows with Putty + pageant or Linux with ssh-agent.