Answer the question
In order to leave comments, you need to log in
How to connect via ssh through a third host (to a different subnet) with one command?
There is a server with two network interfaces 192.168.0.1 and 192.168.1.1
We are on the 192.168.0.0 network, on the other side the machine with the address 192.168.1.2
needs to connect to it via ssh.
Now I will ssh to the server and ssh from it to a machine on a different subnet.
The question is how to connect to a machine in another pdnet in "one touch"?
I do not want to configure routes, machines should not know about other subnets.
It looks like it can be done with 1 command.
You can also configure ~/.ssh/config
Answer the question
In order to leave comments, you need to log in
For OpenSSH 7.3+
In ~/.ssh/config
:
Host target
Name 192.168.1.2
ProxyJump gateway
Host gateway
Name 192.168.0.1
If necessary, through ~/.ssh/config, then
configure authorization by keys and
Write in the config:
HostName 192.168.0.1
Port 22
User user_name_host_1
Host host_2
HostName 192.168.0.2
port 22
User user_name_host_2
ProxyCommand ssh -A host_1 nc %h %p
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question