Ssh connect through another host: Difference between revisions

From Wurst-Wasser.net
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:


=== The solution ===
=== The solution ===
Make sure [[ssh]]d and [[netcat]] ([[nc]]) ist installed and set up on your server. ([[sshd]] on both, [[nc]] only on the "proxy")
Make sure [[ssh]]d and [[netcat]] ([[nc]]) is installed and set up on your server(s). ([[sshd]] on both, [[nc]] only on the "proxy")


Then add this to your <tt>.ssh/config</tt>:
Then add this to your <tt>.ssh/config</tt>:


Host noc noc.mathpeter.net
Host [TARGETHOSTNAME]
     Hostname [TARGETHOST]
     Hostname [TARGETHOST]
     User [USEROONTARGETHOST]
     User [USERONTARGETHOST]
     ProxyCommand ssh [PROXY-HOST-CAN-ALSO-BE-CONFIGURED-IN-.ssh/config] exec nc %h %p
     ProxyCommand ssh [PROXY-HOST-CAN-ALSO-BE-CONFIGURED-IN-.ssh/config] exec nc %h %p


Line 15: Line 15:
* See also:
* See also:
** [[Ssh automagically knocks at server door]]
** [[Ssh automagically knocks at server door]]
** [[Linux]]


[[Category:Linux]]
[[Category:Linux]]

Latest revision as of 09:29, 22 May 2023

The issue

I wanted to connect to a host through another host. And I wanted it as simple as possible to use.

The solution

Make sure sshd and netcat (nc) is installed and set up on your server(s). (sshd on both, nc only on the "proxy")

Then add this to your .ssh/config:

Host [TARGETHOSTNAME]
    Hostname [TARGETHOST]
    User [USERONTARGETHOST]
    ProxyCommand ssh [PROXY-HOST-CAN-ALSO-BE-CONFIGURED-IN-.ssh/config] exec nc %h %p