Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:…. Sorry for wasting comment space, but my rep is not enough for two hyperlinks. – user3672 Jul 29 '09 at 17:40
up vote 3 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.


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
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/
scp user@remote_addr:file .
scp user@remote_addr:file /local/path/file

Copy from local machine to remote server:
scp file user@remote_addr:.
scp file user@remote_addr:/remote/path/
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

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

You must log in to answer this question.