• Zach Pfeffer

SSH Directly to a Machine You'd Normally Need to SSH Into a Server to Get To

This post lists the steps needed to connect to an ssh server beyond an ssh server you have to connect to, to to get to it from a Linux host using OpenSSH.


remote.server.com is the server you ssh into to ssh into the other server

sshbeyondremote.server.com is the server you ssh into from remote.server.com

Replace these names with the names you use when you apply these steps.


1. ssh into remote.server.com from your machine

2. Edit ~/.ssh/authorized_keys and add the public part of ~/.ssh/keys/key1/openssh.keyforremote.priv

3. ssh into sshbeyondremote.server.com from remote.server.com

4. Edit ~/.ssh/authorized_keys and add the public part of ~/.ssh/keys/key1/openssh.keyforsshbeyondremote.priv

5. Log out of sshbeyondremote.server.com

6. Check that AllowTcpForwarding yes in /etc/ssh/sshd_config on remote.server.com

Note, you may have the following:

Big, big warning: you have to ensure that you use the same case in /etc/ssh/sshd_config and in ~/.ssh/config if you use PermitOpen. This seems like a bug because DNS names are case insensitive. If you don't do this you may see:

7. From your machine add the following to ~/.ssh/config

8. Now you should be able to run this from your machine:



Version of the OpenSSH client:

Version of the OpenSSH server: