Upload files with ssh / scp in Linux

R

Rob

Guest
Throughout the day, you'll probably find yourself needing to upload files to various sites/servers. A great secure way to quickly move files around from server to server is to use the scp command. Let's say you need to copy a picture of a donut into your document root on server3.

Code:
scp /home/rob/pictures/donuts/half-eaten.jpg rob@server3:/home/mywebsite.com/public_html/images/

Now, the picture "half-eaten.jpg" is on the mywebsite.com website in the images directory.. Let's work through the command:

scp = our Linux command
/home/rob/pictures/donuts/ = the directory where half-eaten.jpg resides
half-eaten.jpg = our file
rob@server3 = our username on server3
/home/mywebsite.com/public_html/images/ = the directory on server3 where we'd like to put the image

Let's try another one - say you need to grab the logo from that site so you can add a picture of a donut to it in gimp..
Code:
scp rob@server3:/home/mywebsite.com/public_html/images/mylogo.png /home/pictures/

This will grab the logo and put it in your /home/pictures/ directory.

This is a lot more fun if you have SSH keys set up, we also recommend using screen if you're going to be uploading things that may take a while.
 


I don't understand how this works...are you copying files from your local pc or from another server or what?
 
I don't understand how this works...are you copying files from your local pc or from another server or what?

I think it works for anything so long as you know what's the source server and the destination server. Just curious. What does scp stand for? I would think the'cp' means 'copy', right?
 
I don't understand how this works...are you copying files from your local pc or from another server or what?

Yes, from your local linux pc (or where ever your terminal is based.. 'server a')

Picture it like command line ftp.
 
I think it works for anything so long as you know what's the source server and the destination server. Just curious. What does scp stand for? I would think the'cp' means 'copy', right?

Yup.. you're right :)

scp stands for 'secure cp' or 'secure copy'
 
Yup.. you're right :)

scp stands for 'secure cp' or 'secure copy'

Thank you. Just curious. How does it become secure? Does it use an SSL connection like when we log into a https address?
 
This is using ssh to copy the files vs. using FTP or a non-encrypted protocol.
 
This is a lot more fun if you have SSH keys set up, we also recommend using screen if you're going to be uploading things that may take a while.

Adding SSH keys to the mix also makes it far more secure due to the fact your password won't be transmitted via plain-text. :) But, screen is useful I find only if you do not have a tab-capable terminal (i.e.: using putty or a GUI-less box). Its still a very powerful and useful tool, but I think people often overlook the capabilities of terminal emulators (like Konsole) these days.
 
Even the questions are helping me to better understand applications. You have some very smart people on this forum. Thank you to all of you assisting me.
 
The option -r is also worth mentoning. It copies a dir recursively.
 
upload files in folder

I have a question, I've seen this command before and have been trying it out by uploading multiple files in a folder and was unsuccessful. Would this be possible to work? I tried the command with a recursive '-R' and a wildcard at the end of the directory.

Thanks!
 
I am sorry to reply something unrelavant to your post. But I need help.
I don't know how to create new post. I look everywhere, But find no such a button to create new post. Please help!
 
I have a question, I've seen this command before and have been trying it out by uploading multiple files in a folder and was unsuccessful. Would this be possible to work? I tried the command with a recursive '-R' and a wildcard at the end of the directory.

-R is not -r. Most Linux developers don't allow case insensitivity in user input.

What's an example of your command?

I am sorry to reply something unrelavant to your post. But I need help.
I don't know how to create new post. I look everywhere, But find no such a button to create new post. Please help!

There's an orange button right around where the Reply To Thread button is. You have to be inside one of the main forums.
 
its really complicated one to understand, making me frustated now, i dont think it an easy one to go through
 
I'm trying to copy files from my laptop to my server in the basement with this command and it won't work. Perhaps you could give me some advice? Below is the command I've tried:

sudo scp /home/brandon/Documents/3011.jpg [email protected]:/var/www/brandon-PC/

It always tells me the following:

The authenticity of host '111.111.1.11 (111.111.1.11)' can't be established. ECDSA key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00. Are you sure you want to continue connecting (yes/no)?

And every time I say "y" it just asks me again and again and again and again...

Please tell me what I'm doing wrong.

Brandon Doyle
 

Members online


Latest posts

Top