Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have logged on to a system with ssh and there is no scp present on both the systems. How to copy a file without using the scp program.

share|improve this question

migrated from stackoverflow.com Jun 1 '11 at 9:07

This question came from our site for professional and enthusiast programmers.

    
Is netcat (nc) present on both systems? If it is, use your ssh session to tunnel a TCP port and use nc on that port. –  n.m. Jun 1 '11 at 9:06
    
Do you have rsync? –  slhck Jun 1 '11 at 9:08
    
you can also do this: ssh user@remotehost cat /path/to/remote/file > /path/to/local/file –  n.m. Jun 1 '11 at 9:11

3 Answers 3

up vote 23 down vote accepted

To send a file:

cat file | ssh ajw@dogmatix "cat > remote"

Or:

ssh ajw@dogmatix "cat > remote" < file

To receive a file:

ssh ajw@dogmatix "cat remote" > copy
share|improve this answer
    
using cat will not work on binary files. –  ggg Sep 23 '12 at 3:00
7  
@ggg that's not true at all. cd /tmp; cat /bin/bash > test; chmod a+x test; diff test /bin/bash; ./test all works fine. There's nothing inherently "magic" about binary files. Both files in my example compared identical and have the same checksum. It's true that copy and pasting from a terminal window won't work because of things like control sequences and unprintable characters, but using pipes like this these never go near a terminal. –  Flexo Sep 23 '12 at 10:35
2  
Thanks for correcting me, my bad, it really works. –  ggg Sep 24 '12 at 12:31
    
@Flexo I need something like this, the only exception is, I need to pipe in all jpg from a folder. How could iterate through /storage/sdcard1/*jpg and > to files with the same name ? –  George Profenza Jul 3 '13 at 11:58
    
@GeorgeProfenza you'll need to add tar into the mix. tar cvf - /path/*.jpg | ssh foo@bar.com "tar xvf -" or something similar ought to work. –  Flexo Jul 3 '13 at 20:36

Try this:

cat myfile.txt | ssh me@otherhost 'cat - > myfile.txt' 
share|improve this answer
2  
no need for that many cat calls at all –  Flexo Jun 1 '11 at 9:13

Besides piping the file to a remote cat, you may also be able to use some SFTP client to transfer the files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.