How To: Push and Pull Remote Files Securely Over SSH with Pipes

Push and Pull Remote Files Securely Over SSH with Pipes

You can use a secure shell to route traffic or access files, but there's something else you can do. Transfer files. There are loads of solutions for transferring files, like Dropbox, FTP, torrents, etc., but what about for a special ordeal? Most commonly, the way people get shells are from free servers online.

How to Push and Pull Remote Files Securely Over SSH with Pipes

The reason that we consider using free shells a "special ordeal' is because we are often times not allowed to use any form of X session over a SSH tunnel, so programs like Dropbox get ousted, and even FTP, because most servers do not allow hosting of that kind for free. So we need to be able to push and pull files... yet somehow not use anything but the tools that come stock on the server.

Our answer? Pipe commands. And no... not SCP.

In this Null Byte, get ready to learn how to send and receive files over SSH using only pipe commands and some clever command line tricks.


  • SHH client installed
  • Linux

Pushing & Pulling Files

Using strictly pipes and BASH tricks, follow along with me in the video below and watch me push and pull a file named "cow".


cat localfile | ssh cat ">" remotefile

ssh target_address cat remotefile > localfile

You could turn this into a cool Python program, too. I picture something like this would be used to create the shortest possible script.

os.system('cat '+sys.argv[2]+' | ssh '+sys.argv[1]+' ">" '+sys.argv[3])

With a syntax like: <user@host> <localfile> <remotefile>

Be a Part of Null Byte!

Want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from cybersecurity professionals.

Buy Now (90% off) >

Other worthwhile deals to check out:

Photo by metro

Join the Next Reality AR Community

Get the latest in AR — delivered straight to your inbox.


Cool. What a simple, useful trick. If your shell host is blocking SCP, SFTP, etc you can still cat & pipe your files over this way. Short of denying you all write access, this seems bullet proof. Is there another way a shell host could prevent this?

Share Your Thoughts

  • Hot
  • Latest