Copy files over SSH without using SCP

ssh

I'm currently aware of SCP and SSH. There are times when I'm doing some work within a file that I need to download it locally to work on it. Which invokes:

  1. Print the working Directory/Path

  2. Get File name

  3. Fire up new terminal window and do scp myName@host:/Path/to/file/fileName.someExt ~/MyLocalPath

That works great, but it's a major pain in the ass. Is there an easy way to copy a file from a remote server over SSH without using the steps above?

Edit: I am looking for a way to transfer the files from the command line, while I am removed into the box. That way I can run commands and not just copy files.

Best Answer

You can use a FUSE application to mount remote files to the local filesystem. Then you can work on the files directly. When you change them, they will be changed on the remote end automatically.

First make sure you have the fuse kernel module loaded or built-in.

Then you can use either sshfs, which is a standalone application:

sshfs user@hostname: mountpoint # to mount to mountpoint
fusermount -u mountpoint # to unmount

Alternatively, you can use GVFS. If your're in a desktop, just type this into the file manager (or use gvfs-mount in command line):

sftp://user@hostname/

And the filesystem will be mounted to

$HOME/.gvfs/sftp for user on hostname

If however you're not in a desktop, you'll have to start a D-Bus session before you can use gvfs-mount:

$ dbus-launch 
No protocol specified
DBUS_SESSION_BUS_ADDRESS=XXXXXX
DBUS_SESSION_BUS_PID=YYYY
$ export DBUS_SESSION_BUS_ADDRESS=XXXXXX # copy value from above

You can automate the above by a shell script which you source (!).

Related Question