How to Upload a File via SSH and Command Line

By  on  
scp ~/Downloads/NestedT.png root@64.207.144.103:/var/www/vhosts/davidwalsh.name/httpdocs/demo

My preference for daily work is usually GUI applications, like Visual Studio Code for text editing and Cyberduck for remote file server management. I'm also a huge fan of automation, so I do try to learn the command line equivalents of UI functions. My latest desire was wanting to know how to upload a file via SSH from command line.

To upload a file to a remote server from command line, use scp and the file path with the remote destination:

scp path/to/local/file.png user@hostname:/path/to/upload/

I'll be honest: I'll probably still use a GUI for personal uploading, but knowing how to upload via automation is still super valuable!

Recent Features

Incredible Demos

  • By
    JavaScript Copy to Clipboard with Branding

    I published a post a year ago detailing how you can copy to the clipboard using JavaScript.  The post was very popular and why would it be?  Copying content from a webpage without needing to use the default browser functions is awesome.  One trend I've...

  • By
    CSS Fixed Positioning

    When you want to keep an element in the same spot in the viewport no matter where on the page the user is, CSS's fixed-positioning functionality is what you need. The CSS Above we set our element 2% from both the top and right hand side of the...

Discussion

  1. mc

    Its worth noting that scp is considered deprecated.

    https://lwn.net/Articles/835962/

    I’ve moved to rsync for all of my needs in this regard.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!