Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-07-2007, 08:10 PM
|
#1
|
|
LQ Newbie
Registered: Feb 2007
Posts: 14
Rep:
|
Copy file from Server to Local Host
Hi,
I like to copy a file from the server to local host. What will be the command? I can ssh to server and now want to copy the file to my local directory. I am using Redhat.
Thanks.
|
|
|
|
02-07-2007, 08:26 PM
|
#2
|
|
Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,817
|
Can you reach the local machine from the server by IP? Or on other words, are you on a host that the server can contact on the LAN, rather than being behind a firewall/NAT at a remote location (as in, from a school, office, etc).
If the server and the client are on the same network, you can simply log into the server with SSH, and run a command like this:
scp ./filename username@localIP
So if you wanted to move the file "Test.txt" to the computer at 192.168.1.120 as user tom, you would do:
scp ./Test.txt tom@192.168.1.120
Assuming the machine is running an SSH server, that will copy the file over to it.
|
|
|
|
02-07-2007, 10:05 PM
|
#3
|
|
LQ Newbie
Registered: Feb 2007
Posts: 14
Original Poster
Rep:
|
Hi,
Thanks for the quick reply. Following command works very fine. but I was not able to trace it in local machine. I was not able to find the copied file in local machine. From the server it says 100% complete.
the local user name is root@IP address. Where I will find it? Thanks.
Regards,
Fazlur.
|
|
|
|
02-07-2007, 10:14 PM
|
#4
|
|
Member
Registered: Jan 2007
Posts: 133
Rep:
|
try /root. Or run find / -name 'filename'
|
|
|
|
02-07-2007, 10:23 PM
|
#5
|
|
Member
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851
Rep:
|
Hi foysol_bgd,
you can do this:-
scp file.txt root@server:/root/file.txt (or /home/root/ if you lazy)
scp -r folder root@server:/root (for recusively copy folder)
Regards,
Ks
|
|
|
|
02-08-2007, 01:37 AM
|
#6
|
|
Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,817
|
Yes, my apologies.
After the user and IP address of the destination, you need to give the location you want to save the file to.
So the full command would look like:
scp ./Test.txt tom@192.168.1.120:/home/tom
|
|
|
|
02-08-2007, 10:43 PM
|
#7
|
|
LQ Newbie
Registered: Feb 2007
Posts: 14
Original Poster
Rep:
|
thanks everyone for the help. I really appreciate that. It is working fine now.
|
|
|
|
02-09-2007, 01:52 AM
|
#8
|
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
Rather than ssh'ing to the server and performing an scp on the server, which establishes a 2nd ssh connection back from the server to your local machine, you're better off doing it all in one scp command on the local host:
Code:
scp you@remoteServer:/path/to/file /path/on/local/machine/
In other words, scp accepts user@server: prefixes to path for both source and destination...
|
|
|
|
02-10-2007, 12:35 AM
|
#9
|
|
LQ Newbie
Registered: Feb 2007
Posts: 14
Original Poster
Rep:
|
Thanks timmeke. It is great.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:33 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|