I am writing a script which needs to be able to access a server with limited access. I wish to do this by going through another unix server which I do have access to and also has access to the other computer.
I can SSH into the second machine from home an not be prompted for a password, since I generated an SSH key and using ssh-copy-id. When I am physically at the second machine, I can SSH into the third in the same manner, with out being prompted for a password.
However, when I SSH into the second and then try to SSH into the third, I am prompted to the pass-pharse for the key and the password for the third computer.
Why does this happen, and how can I stop this prompt?
EDIT: To clarity some points.
- I do not have root permission on either machine I am SSHing into, only my machine at home
- I missed typed above (now fixed). While physically at the second machine I can SSH into the third server.
Diagram
Machine A : Home machine, root access
| SSH (passwordless)
v
Machine B : Publicly accessible server, no root permissions
| SSH (passwordless while physically logged in,
| password prompted while at machine A SSHed into machine B)
v
Machine C : Only accessable on campus
(which B is and A is not), no root permissions
You mention being able to get into the 2nd machine from the 1st, and the 1st to the 2nd. So if there is a 3rd machine in the chain you need to setup SSH keys on the 3rd machine or get the public key off of the 3rd machine you mention.
Another good tip is to manually run SSH with the verbose/debugging (
-v) option so you can see exactly what is happening at each step.This has saved me a lot of headaches in the past by showing me exactly how the login process is flowing & what exactly is clogging it up.
So if somehow your 3rd machine is named
machine3.localthen your ssh command using verbose mode would be:EDIT: Original poster says that he is being asked for a passphrase for a key he generated for the 3rd machine. If that’s the case, that’s the problem. You can’t have a passphrase on an SSH key if you want passwordless access.
ANOTHER EDIT: Also, be sure they have permissions that match the following & are owned by the account trying to access like this example shows: