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?
Supposing the intermediate host is allowing tunnels, 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 create a tunnel to the SSH destination.
This is equivalent to adding instead in
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.