LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 02-07-2007, 08:10 PM   #1
foysol_bgd
LQ Newbie
 
Registered: Feb 2007
Posts: 14

Rep: Reputation: 0
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.
 
Old 02-07-2007, 08:26 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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.
 
Old 02-07-2007, 10:05 PM   #3
foysol_bgd
LQ Newbie
 
Registered: Feb 2007
Posts: 14

Original Poster
Rep: Reputation: 0
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.
 
Old 02-07-2007, 10:14 PM   #4
wahming
Member
 
Registered: Jan 2007
Posts: 133

Rep: Reputation: 15
try /root. Or run find / -name 'filename'
 
Old 02-07-2007, 10:23 PM   #5
kstan
Member
 
Registered: Sep 2004
Location: Malaysia, Johor
Distribution: Dual boot MacOS X/Ubuntu 9.10
Posts: 851

Rep: Reputation: 31
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
 
Old 02-08-2007, 01:37 AM   #6
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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
 
Old 02-08-2007, 10:43 PM   #7
foysol_bgd
LQ Newbie
 
Registered: Feb 2007
Posts: 14

Original Poster
Rep: Reputation: 0
thanks everyone for the help. I really appreciate that. It is working fine now.
 
Old 02-09-2007, 01:52 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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...
 
Old 02-10-2007, 12:35 AM   #9
foysol_bgd
LQ Newbie
 
Registered: Feb 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks timmeke. It is great.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp: copy a file from local machine to remote machine seran Linux - Newbie 8 10-30-2007 12:23 PM
nfs / nis problem - slow copy to servermounts but fast from server to local hdd krischeu Linux - Networking 1 06-09-2005 11:05 AM
Sendmail and the local-host-names file vpatton Linux - Software 5 04-26-2004 07:37 PM
client can't copy files to local machine through vsftpd server on RH9 tree_buddy Linux - Networking 7 09-15-2003 10:54 AM
using dd to copy a file system to another server bobbyr Linux - General 2 08-17-2003 12:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration