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!
Thank you! Unfortunately I have two problems: sshpass does not have an option -L, so I replaced sshpass by ssh, is that ok? And "ssh -p 2222 localhost" gives me the following error: "ssh: connect to host localhost port 2222: Connection refused" Do I need to open port 2222? I am new to this, sorry for asking. – Daniel Förster – 2016-03-03T16:53:40.403
Yes. I forgot thy syntax again. But the though was that you don't have to write the
expect
script, but you might usesshpass
to "take you" to the first server. Edit: Give a try the first command with verbose logging (-vvv
). The port forwarding might not be allowed. – Jakuje – 2016-03-03T16:57:20.117Ok, thanks, I guess this would work. I realize now however that port forwarding is prohibited by the jumpbox. – Daniel Förster – 2016-03-03T17:03:13.467
I modified the answer for the case with prohibited port forwarding on jumbox. But I didn't test it so there might be still some glitch. Let me know if it works for you. – Jakuje – 2016-03-03T17:11:31.180
Great! I see the files in nautilus. Your .ssh/config entry "Host remote" did the trick when entered in nautilus connect to server dialog. However I think your line "SSHPASS=password sshpass -e ssh jumpbox" should be replaced by "SSHPASS=password sshpass -e ssh remote" (?) And "ssh remote-forwarded" also did not work (Error: "ssh: connect to host localhost port 2222: Connection refused"), but it was not necessary. – Daniel Förster – 2016-03-03T17:32:53.823
Yes. Of course. My bad. There was also typo in the
LocalForward
option. Can you give it one more try? – Jakuje – 2016-03-03T17:36:24.633This works now, but I don't see a big difference between
ssh remote
andssh remote-forwarded
. Both work just fine, is it a question of entering the password? Another point is that I did not succeed withSSHPASS=password sshpass -e ssh remote
and usedssh remote
instead. Anyway as I said, entering a password doesn't bother me in command line and nautilus can save the password. Maybe for others having the same problem: Don't forget to specify your user names on the different machines, for example via a "User username" entry in.ssh/config
. Thank you so much! – Daniel Förster – 2016-03-03T18:19:23.767Especially thank you for a solution without an
expect
script. I didn't like this idea anyway. – Daniel Förster – 2016-03-03T18:28:26.173Yes, exactly as you write. The
remote-forwarded
should not need the password for proxy. Please, also don't forget to mark this answer as a solution, if it solved your problem. – Jakuje – 2016-03-04T00:29:28.520