LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   scp command (Remote to Local ) (https://www.linuxquestions.org/questions/linux-newbie-8/scp-command-remote-to-local-887147/)

gardenair 06-19-2011 03:07 AM

scp command (Remote to Local )
 
I am using cent os 5. I successfully copy a file from to my local computer to remote computer

PHP Code:

# scp file1.txt 192.168.1.10:/home 

The issue is how can I copy a file from remote computer to local machine ?

I have google but still fail to fetch file i.e remote to PC...> To ....> Local PC

thanks in advance,
garden

druuna 06-19-2011 03:10 AM

Hi,

Code:

scp 192.168.1.10:/home/file1.txt file1.txt
Hope this helps.

gardenair 06-19-2011 04:35 AM

thanks for the reply. Sorry I for get to write the IP settings. The IP Settings are

Local PC:- 192.168.1.10

Remote PC:- 192.168.1.20

Thnaks,
garden

siranjeevi 06-19-2011 04:47 AM

Hi,

Try the following command

Quote:

scp user@192.168.1.20:/home/file1.txt file1.txt
Hope this helps

ssrameez 06-19-2011 10:05 AM

Hello gardenair

Practise checking the man pages..

"man scp" will give more details about usage.

gardenair 06-20-2011 12:20 AM

thanks all for the reply. Well I have tried the following code.

PHP Code:

[root@localhost root]#scp 192.168.1.20:/home file1.txt
root@192.168.1.20's password:
scp: /home not a regular file
[root@localhost root] 

Description:. I want to copy a file i.e file1.txt from remote computer i.e 192.168.1.20 to my local computer home directory.
I have also checked 1st the man page but there was still confusion.

kindly guide me .
thanks
garden

markush 06-20-2011 12:45 AM

try
Code:

scp 192.168.1.20:/home/file1.txt .
the scp command works exactly like the cp command.
Probably you mean file1.txt in a users homedirectory, if the users name is gardenair, you may write
Code:

scp 192.168.1.20:/home/gardenair/file1.txt .
if you do it as root you will be asked for root's password, if you do it as the user you'll have to enter the user's password.

Markus

networking.dept 06-20-2011 01:09 AM

@gardenair,

First execute pwd command to know where are you right now,

If your pwd is /home/gardenair then execute scp scp 192.168.1.20:/home/gardenair/file1.txt . as markush explained.

If you are into some other directory then execute scp 192.168.1.20:/home/gardenair/file1.txt /home/gardenair/

This error "scp: /home not a regular file" is because you are trying to copy directory, If you want to copy directory through scp then you have to provide option -r

Hope this helps you.

BradMarks 07-19-2011 01:07 PM

I'm trying to do the same thing that gardenair is/was (sad when we never find out if our suggestions help or not). I say:
scp root@139.64.100.1: /usr3/d/HRF

I want to move the file HRF from /usr3/d/ on the server whose IP is 139.64.100.1 to my current attch point on the local server. No matter what I try I keep getting the .: not a regular file error message.

Any help would be greatly appreciated and I'll let you know if it helps or not! :D

-Brad

druuna 07-19-2011 01:22 PM

Hi,
Quote:

Originally Posted by BradMarks (Post 4419262)
I'm trying to do the same thing that gardenair is/was (sad when we never find out if our suggestions help or not). I say:
scp root@139.64.100.1: /usr3/d/HRF

I want to move the file HRF from /usr3/d/ on the server whose IP is 139.64.100.1 to my current attch point on the local server. No matter what I try I keep getting the .: not a regular file error message.

There's an extra space that should not be there and you need to set the destination:
Code:

scp root@139.64.100.1:/usr3/d/HRF HRF
You don't have to give the filename, you can also use a . (dot) to tell scp to copy the files to the directory you are standing in:
Code:

scp root@139.64.100.1:/usr3/d/HRF .
BTW: It is not a good idea to do this as root user. If at all possible do this as a normal user.

Hope this helps.

BradMarks 07-19-2011 01:30 PM

Drunna,
Thank you so much. That did the trick!
-Brad

Reuti 07-19-2011 01:42 PM

NB: If you do this often and don’t want to write the TCP/IP address all the time, you can create a file ~/.ssh/config which will also bo honored by scp and put therein:
Code:

Host local
    Hostname  192.168.1.10

Host remote
    Hostname  192.168.1.20

Host foobar
    User      root
    Hostname  139.64.100.1

and use then:
Code:

scp foobar:/usr3/d/HRF .

BradMarks 07-19-2011 01:58 PM

Thanks, Reuti. That makes for a few fewer keystrokes!

Thanks to all for your help. I'm sure I'LL BE BACK! :D

chrism01 07-19-2011 06:09 PM

In general, its
Code:

scp <user>@<machine>:/path/to/file <user>@<machine>:/path/to/file
user is optional if same at both ends, else specify user for remote, not for local; specify machine for remote system only; must specify path for remote, specify path or '.' for local target.

HTH

Reuti 07-19-2011 06:13 PM

Quote:

Originally Posted by chrism01 (Post 4419549)
; must specify path for remote, specify path or '.' for local target.

NB: here it’s worth to add, that the path could be relative and if not specified on the remote side it’s the home directory of the user and the relative path specification can start there.


All times are GMT -5. The time now is 02:15 PM.