For transferring files between two Linux machines I always felt more comfortable using the graphical file managers such as Nautilus, which offer the option to connect to a remote machine via SSH. However today I need to transfer files to a machine I cannot access directly -- I need to first SSH into a certain server and then do another SSH into my final destination. Is there still a way to do a GUI-friendly file transfer here or should I just fall back to good-old command-line scp this time?

  • Does the intermediate server allow tunnels? – A.B Jan 21 '19 at 20:14
  • I have no idea, but feel free to answer assuming they do :) – hugomg Jan 21 '19 at 20:15

Supposing the intermediate host is allowing port forwarding, you can do half of the work using command line and finish graphically as usual.

sshfs -o ssh_command='ssh -J firstuser@firsthost' finaluser@finalhost:directory localdirectory

This will instruct sshfs to run its ssh backend (itself running the sftp subsystem in the end) with an additional -J option, equivalent to the ProxyJump configuration option, which itself will transparently forward the SSH connection to the destination.

This is equivalent to adding instead in $HOME/.ssh/config:

Host finalhost
    ProxyJump firstuser@firsthost

and just run sshfs finaluser@finalhost:directory localdirectory, or else you can also put the above two lines in a file and use the -F option of sshfs with this file.

Now your directory localdirectory is usable with Nautilus or any other tool, GUI or not (but usually limited to the user running sshfs, as usual).

It's quite possible that having this option in $HOME/.ssh/config will allow your GUI tool to transparently work as usual to mount the directory, thus not needing CLI anymore. I couldn't test this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.