0

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?

4
  • 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? Dec 24, 2012 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, 2012 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. Dec 26, 2012 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, 2012 at 20:39

3 Answers 3

0

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: http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html

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.

0

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.

0

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

sftp

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

or

dd if=file.to.transfer | 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.

You must log in to answer this question.

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