Solved

SSH Copy Local File to Remote Server

Posted on 2011-09-27
14
387 Views
Last Modified: 2012-08-13
I have 3 .sql database dumps that I need to import via command line because they are each over 3G in size.  I am not that advanced in command line management, so I'm not sure if I'm doing this right.

I have the .sql file located in a local folder, ex: C:\databack\inboxcor_311_leads_dump.sql , but I keep getting a "No such file or directory" error when trying to run the scp copy command.  I'm sure I'm not putting the path right, so if somebody could help me.....?

When logged in to PuTTY as root:

scp /databack/inboxcor_311_leads_dump.sql root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack



scp /databack/
0
Comment
Question by:kageboy2003
  • 9
  • 4
14 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713623
I'm confused.  So you are on a Windows machine, your .sql files are on that same machine, and your target box is some Unix server correct?

Use WinSCP to get the files over.

There is also PSCP from the same people as PuTTY, but I prefer WinSCP.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713637
If you were logged into your Unix/Linux box, and typed the following:
scp /databack/inboxcor_311_leads_dump.sql root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack

Open in new window


It would try to copy /databack/inboxcor_311_leads_dump.sql on the Unix machine to root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack, which I'm guessing is the IP of the same Unix machine, correct?

In that case the error you received was because the file /databack/inboxcor_311_leads_dump.sql does not exist on your Unix machine, and if it did, and that IP is in fact the same machine, then you would have copied /databack/inboxcor_311_leads_dump.sql to /var/www/vhosts/inboxmediacorp.com/httpdocs/databack.
0
 

Author Comment

by:kageboy2003
ID: 36713649
The local machine is my Windows computer at work.  I am trying to get the files uploaded to our remote server (UNIX) and I was under the impression that using SCP is faster than FTP.  

I do have WinSCP as you suggested, and I noticed that when I login as root, I don't see the folders I need to upload too.  Maybe I need to login as a FTP user rather than root?
0
 

Author Comment

by:kageboy2003
ID: 36713651
Sorry...in regards to your question...no they are two different IP's and machines.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713663
When you login via WinSCP, you are going to be placed in the users home directory just like if you were to SSH in.  you will need to navigate through the filesystem to get to your destination -- ".." means parent directory, but you can probably type in an absolute path as well.

If you were to login via FTP, it would require an FTP server be listening on the Unix side, and even then you would be locked into only the directories that the FTP server was setup to use.
0
 
LVL 21

Accepted Solution

by:
Papertrip earned 500 total points
ID: 36713677
Ah misread your last statement, you said ftp user as opposed to ftp server.

If you can login as root, then you are fine, no need to login as any other user (although it might create a permissions issue in your Apache directory when you copy it, unless setgid is turned on for the directory.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713680
Login as the user that you would normally use to copy files for your web server.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:kageboy2003
ID: 36713708
OK.  I'm going to go ahead and use WinSCP, but can you tell me why I wasn't able to do it from the command line in PuTTY?  I'm trying to learn my way around the command line and wanted to know for future experience.  Did I have the path wrong?  I even tried with the \ in the path for Windows and I still got the error.  What would have been the proper path to a local computer file?

Thanks.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713727
I tried to explain it in http:#36713637 but I know it wasn't very clear, so here is a better version.

What would have been the proper path to a local computer file?
That's just it -- you were on the Unix box while using scp, that makes C:\databack\inboxcor_311_leads_dump.sql a remote file.
0
 

Author Comment

by:kageboy2003
ID: 36713748
I still am a bit confused.  So you're saying that I would have had to login to my local computer in order to do the copy?  All the examples I read did not mention anything about that.  

Also, is SCP transfer actually faster than FTP?  That was the only reason I wanted to try from the command line because I understand it is a faster process.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713830
scp /databack/inboxcor_311_leads_dump.sql root@50.30.33.46:/var/www/vhosts/inboxmediacorp.com/httpdocs/databack

That says take the file /databack/inboxcor_311_leads_dump.sql on the Unix box and copy it to /var/www/vhosts/inboxmediacorp.com/httpdocs/databack on the Unix box.  The actual source file from the is still on the Windows machine, you haven't copied to the Unix box yet.

You are running scp on the Unix machine right? 50.30.33.46 is that same Unix machine right?
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713861
Using SCP with compression turned on for a file like an SQL dump will most likely be much faster than normal FTP.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 36713876
Compression is only really useful for slow links.  In general, scp is slower than FTP because of the encryption overhead.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36713939
@Tintin
Yeah definitely most useful for slow links, but what about something like a large text file over a normal link?  I admit I have never tried it since I would just gzip the file first, can't test it right this moment.

Speaking of that, kageboy you should just compress that file first then use either scp, or FTP if you prefer.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PERL - Find newest folder 12 117
Choosing the right language for new project 8 61
Sed question 2 68
Using an inventory file in a script 7 12
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now