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

  • By
    Create a CSS Cube

    CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals.  Add animation and you've got something really neat.  Unfortunately each CSS cube tutorial I've read is a bit...

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

Incredible Demos

  • By
    Geolocation API

    One interesting aspect of web development is geolocation; where is your user viewing your website from? You can base your language locale on that data or show certain products in your store based on the user's location. Let's examine how you can...

  • By
    Fade Images with MooTools LazyLoad

    I recently received an email from a MooTools developer asking a great question about my LazyLoad class: "I'm using your LazyLoad MooTools plugin (which is great, by the way). I have been trying to figure out how to modify it so that once an image scrolls into...

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!