Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SSH tunnel in .ssh/config with public key on second leg

I want to reach Ubuntu20.04 server U1 through Ubuntu20.04 server U2 since U1 is behind a firewall, from a MacBook with BugSur. SSH from U2 to U1 is done with a public key, without password. I get to U2 using password but the next step always asks for a password (which I can’t remember now). I have seen this question and tried things like this in the MacBook’s .ssh/config:

Host U2
    HostName accessible.uni.com
    User me
    # PreferredAuthentications publickey
    ForwardX11 yes

Host U1
    HostName behind_firewall.uni.com
    User me
    # PreferredAuthentications publickey
    # IdentityFile /home/me/.ssh/id_rsa.pub
    ProxyJump U2
    ForwardX11 yes

and running ssh U1 enter the password for U2 but is then asked for password for U1. How can I make it work password-free on the second ssh?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use Remote Command. Once it’s successfully connected to U2 it will execute the command ssh U1.

Host U1
    HostName accessible.uni.com
    User me
    # PreferredAuthentications publickey
    ForwardX11 yes
    RemoteCommand ssh U1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading