0

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.

5
  • If the machine you want to transfer the file to accepts ssh connections, just run scp on the remote machine to transfer the file where you want it. Commented Oct 3, 2011 at 2:22
  • I'm behind a router and firewall. Not ideal. Commented Oct 3, 2011 at 2:35
  • I might be misunderstanding your question, but if you want an easier way to copy files with ssh, you can use the FISH kioslave (if you're using KDE) or GVFS (if you're using GNOME). Commented Oct 3, 2011 at 2:38
  • I'm looking for a way to transfer from the command line, no from a GUI. Basically I ssh into a box. something like SomeCommand FileOnHost ~/localPath would be ideal. Think of the connection as both a shell and a bridge for files and commands. Commented Oct 4, 2011 at 4:37
  • Neovim with the --server and --client commands might do the trick. Commented Aug 11, 2023 at 13:49

3 Answers 3

2

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 (!).

2
  • I very much like FUSE/sshfs, but this is a Linux-only solution. Commented Oct 3, 2011 at 8:02
  • eldering: FUSE is far from being Linux-only. According to Wikipedia, it's available for Linux, FreeBSD, NetBSD, OpenSolaris, and Mac OS X. Commented Oct 3, 2011 at 9:38
1

I don't know of any native method, but there is a patch, "ssh-xfer": http://matt.ucc.asn.au/ssh-xfer/

ssh-xfer is a hackish but handy way of transferring files from remote hosts to your local computer. Firstly, you need to run a slightly modified SSH authentication agent program on your local computer. Patches are available for both OpenSSH and PuTTY . . .

I haven't tried it myself, so no promises here. It looks like you have to install ssh-xfer on the remote host, so that may not work out if you don't own the machine (shell account, etc.)

0

Know this is old, but you mentioned you can't scp back because of a firewall. That can be easy to fix if you can use ssh remote forwarding? Something like ssh -R 22223:localhost:22 [email protected] would become your ssh command.

Then you can scp back to the originating server on port 22223 using a command like scp -P 22223 test/a user@localhost:~

On the remote host, you'll need /etc/ssh/sshd_config set to AllowTcpForwarding yes (it often is, but not always). It might also be helpful to add the following to ~/.ssh/config

Host homecomputer Port 22223 User username HostName localhost 

Then you could send stuff back with scp or ssh without specifying a port. You also might want to investigate passwordless ssh to avoid typing passwords, if you haven't already.

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.