Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to move 5 gigs of files from one remote host onto another remote host, which does not make the scp command available via the console. So i'm contemplating any other options than first downloading the files to my local machine, only to reupload them to the final server.

The target server uses sftp. Would it be possible to launch an sftp "download" to the target server via the ssh console?

If so, what are the command schemes?

share|improve this question
Please validate this: you want to move files on boxA to boxB, but you have to do that from boxC, correct? I assume you can login via ssh to any of the boxes, yes? – jim mcnamara Dec 24 '12 at 22:39
yes to all. Problem is: boxC has very little commands available for remote transfer. no scp at least. So i'm looking at alternative options. – pixeline Dec 25 '12 at 19:39
Good. Last question: Are ssh-keys installed on all three boxes? If yes it will make the mish-mash of an all ssh|tar transfer simpler. – jim mcnamara Dec 26 '12 at 1:28
have no idea. i'm sorry i'm just learning as i go here with ssh. I remember have to accept keys on first sftp connection, which worked. maybe you can elaborate on the ssh|tar transfer method? I'll test that and report. – pixeline Dec 26 '12 at 20:39

ssh keys mean that as some user, say pixeline, when you are logged on to serverC, when you type

ssh serverA

It connects you directly with asking for a password.

IF there are keys then this should work for you

#copy from serverA to serverB from serverC - you are logged to serverC
   ssh pixeline@serverA  'cat /path/to/filename | ssh pixeline@serverB "cat > /path/to/remotefilename " '

It will not work well without ssh public keys - this is a step by step how to:

NOTE: your home directory has to have protections 755 at least and the .ssh directory under home should be 700. On all 3 servers.

Have fun... You MUST get that working, and if you want to do all the files at one time we can try tar.

share|improve this answer

If all the servers are linux or unix based you might be able to use rsync as it would be the fastest way to complete it.

share|improve this answer

If sftp is available on the remote server, the command to invoke it would be (drum-roll please):


It works just like almost any other CLI FTP program. Explaining all the things you can do with it is a bit large for a superuser answer, so just read its manpage.

Now, it would be a bit unusual for a system to be configured to forbid scp, but allow sftp. Not that it can't be configured that way, but most admins who block one block the other.

If you find yourself in that boat, then you can leverage the fact that ssh lets you execute remote commands via any archive or copy program that will work with stdin and stdout. For example:

tar -c <files or directories to archive> | ssh user@host tar -x


dd | ssh user@host dd of=destination.file

This works because if these programs don't have a file specified, they default to stdin or stdout as appropriate. So you create an archive or slurp a file and dump the result to stdout, and then you pipe that stdout to the stdin of ssh, which is running a program that will convert it back into the files you want.

Depending on your network conditions and file characteristics, you may want to invoke the sftp or ssh portions of these commands with -C to compress the traffic so it doesn't take as long.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .