can I access ssh server by using another ssh server as intermediary
If you have OpenSSH 7.3p1 or later, you can tell it to use server1
as a jump host in a single command:
ssh -J server1 server2
See fcbsd’s answer for older versions.
You need to use ssh port forwarding and depending on what you want you either want the -L
option or the -R
option.
ssh server1 -g -L 2222:server2:22
the -g
allows remote hosts to connect to local forwarded ports, and the -L
sets up a connection on server1 port 2222 to connect to server2 port 22.
Thus on server1 ssh localhost -p 2222
will connect you to server2.
If you have problems use -vvv
that will help give lots of debugging output.
The -R
sets up a reverse tunnel, so connections on the remote host are forward to the local side.