8

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?

2
  • Does the intermediate server allow tunnels? Commented Jan 21, 2019 at 20:14
  • I have no idea, but feel free to answer assuming they do :) Commented Jan 21, 2019 at 20:15

1 Answer 1

18

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 

or actually, since -o ProxyJump (which is the same as -J for ssh) is accepted directly by sshfs (which will then provide it to its ssh backend), this can be rewritten as:

sshfs -o ProxyJump=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 ProxyJump 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.

1
  • 2
    Using -o ProxyJump=firstuser@firsthost option is also possible, without the need to edit config files. Commented Feb 10, 2024 at 17:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.