Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose you have root access in an unknown server. You want to copy a file from the server to your local machine. Source of the snippet in the title.

Challenge: copy to a file from the unknown server, where you have root rights, to your local machine

ROOT+SERVER+FILE+Unknow    ----    Commands?    --->     FILE+LOCAL+YOUR+COMP
                                   scp? how?

Please, give some example.

share|improve this question
    
Related question is here: superuser.com/questions/15182/…. Sorry for wasting comment space, but my rep is not enough for two hyperlinks. –  user3672 Jul 29 '09 at 17:40

3 Answers 3

up vote 2 down vote accepted

Well, you cannot copy something to an unknown server. You will have to know its name and you will have to have an account on that machine.

The link you gave tells you how to copy something from server X to server Y issuing the command on your local machine.

EDIT:

If I understand you correctly, you want to find out on what machine you are.

You could use the hostname -f command that should give you the complete hostname. But to copy something from that machine to another server, you don't need that information, you just do the following:

scp file user@server:
share|improve this answer
    
but even with known servers or a server and my local machine, how can I get the information to the snippet? –  user3672 Jul 29 '09 at 16:46
    
I really don't understand. What kind of information are you looking for? –  innaM Jul 29 '09 at 16:51
1  
Thank you! I chose your answer because of you being the first with the simplest example. Unfortunately, my rep is not enough for upvotes. Thanks again. –  user3672 Jul 29 '09 at 17:19

scp works just like cp or rcp, SOURCE is the first argument, DESTINATION is the second.

  • Copy file from a server to current directory on local machine

    scp user@server:/path/file .

  • Copy file from a server to a different server

    scp user@server:/path/file user@different_server:/path/file

share|improve this answer

Suposing you know the name of the host, you can do

Copying to local machine from remote server:
scp user@remote_addr:file /local/path/
or
scp user@remote_addr:file .
or
scp user@remote_addr:file /local/path/file

Copy from local machine to remote server:
scp file user@remote_addr:.
or
scp file user@remote_addr:/remote/path/
or
scp file user@remote_addr:/remote/path/file

One could use scp even to copy local to local (like cp):
scp file /local/path/file2

EDIT:
If you are logged in the remote server, consider remote_addr the address of you computer and de unknown server the local machine. Is that what you want?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.