2

In order to automate a ssh connection, I wrote a script using expect, which works just fine. However, I would like to use this script in the nautilus connect to server function. My idea was to include this expect script somehow into the .ssh/config file since nautilus is able to use the connections detailed there, but I don't know how. Unfortunately, I cannot copy an RSA key to the server. It is a multihop connection, and I cannot write to the first server. This first server only asks for a password and the machine to which I can connect. So, the password is not really the problem, as it could also be supplied by nautilus. Any help is appreciated, thank you!

1 Answers1

1

You can't use password in ssh_config. But you might use port forwarding (if allowed on the jumpbox):

SSHPASS=password sshpass -e ssh -L 2222:remotehost:22 user@jumpbox

and then

ssh -p 2222 localhost

will bring you directly to the remote host. You can put that into your ssh_config, such as:

Host remote-forwarded
  Hostname localhost
  Port 2222

and then connect such as

ssh remote-forwarded

Similar way it will work in nautilus.

Port forwarding prohibited on jumpbox

In this case it will get more complicated. You will need to use proxy command to set up port forwarding directly from the remote host. You config will be longer:

Host remote-forwarded
  Hostname localhost
  Port 2222
Host jumpbox
  Hostname jumpbox-host
Host remote
  Hostname remote-host
  ProxyCommand ssh -W %h:%p jumpbox
  LocalForward 2222 localhost:22

Otherwise it should work the same way, first

SSHPASS=password sshpass -e ssh remote

and then directly to the other host:

ssh remote-forwarded
Jakuje
  • 10,827