How to 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.

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.

Requirements

  • 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”.

Commands

cat localfile | ssh user@server.com 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:

program.py <user@host> <localfile> <remotefile>

Be a Part of Null Byte!

Photo by metro

Via How to Push and Pull Remote Files Securely Over SSH with Pipes on null-byte.wonderhowto.com.

Related:


Go to Source

 

Comments are closed.