2

I have my Linux workstation where I run a virtual machine with another Linux.

The point is that my friend would like to try make ssh connect directly to my virtual machine, but we are not able to make it work.

ssh -R 2223:linda@virtualMachine:221 linda@workStation

This is how we tried it (we tried a lot of options, but this is basically the first idea). SSH on virtual machine listening on port 221, so that is why we use this port.

The problem is, that with this command, he connects to my workstation instead of virtualMachine.

Why is that happening? Isn't this the way to forwarding SSH connections to the virtualMachine address?

Kusalananda
  • 333,661
dvory59
  • 75

1 Answers1

0

You could use two ssh commands, one for the tunnel, then another one for login (unless you forward/route ports which you are currently not doing):

ssh -f -l linda -L 2211:virtualMachine:221 workStation -N

Then

ssh -l linda -p 2211 localhost

and log in to virtualMachine here.

EDIT: Also try (suggested by francois P)

ssh -J linda@workStation linda@virtualMachine:221

EDIT2: If the problem persists this may be due to options on the jump host (workStation), please also see here: SSH tunneling error: "channel 1: open failed: administratively prohibited: open failed". Specifially, see whether on workStation the file /etc/ssh/sshd_config has these lines

AllowTcpForwarding yes
PermitOpen any
PermitTunnel yes

Restart sshd after changes to the file:

systemctl restart sshd
Ned64
  • 8,726
  • I am trying this one, but i get error like : Bad stdio forwarding specification '192.168.122.153:221:22' ssh_exchange_identification: Connection closed by remote host ... Is alright, that it automatically add port 22 to the end? – dvory59 Sep 02 '19 at 11:49
  • @dvory59 Did you try the first two commands, or the last one? – Ned64 Sep 02 '19 at 11:55
  • the last one.. We can easily use just two ssh connections, like ssh in ssh, first connect to work station, and then connect to virtual machine.. But i don't think that it's the best solution – dvory59 Sep 02 '19 at 12:47