I have a centos server lets say with ip: I want to download a file from at path /root/pc/filename.rar to my localhost host (current pc). What command I need to download that file? I am trying like this but its not working

scp root@

I want to download that file into my system current directory.

3 Answers 3


Just add where you want it to be copied to (ie: ./):

scp root@ ./
  • how can I download file with required rsa file and port
    – huykon225
    May 19, 2021 at 3:16
  • 1
    It should ssh -i /path/to/id_rsa -P 2222 root@ ./ the character P should be uppercase .
    – huykon225
    May 21, 2021 at 1:53

First of all, make sure that the root user is really needed to access the file. If the file can be retrieved by a normal user, that would be preferred to limit the security risks.

If root is really required, make sure that root is actually allowed to login by ssh by checking your /etc/ssh/sshd_config file and see if the PermitRootLogin option is set to yes.

Finally, your command above should work when you add a . (pointing to your current dir) behind it, like so:

scp root@ .

Or you can always use a full path as well:

scp root@ /home/user/pcfilename.rar

I'm using

rsync -avz example@x.x.x.x:/home/example/* .

This example will deliver files inside the folder (-a switch), will print the process (-v switch, verbose) and will use compression during the transfer (-z switch). The dot in the beginning tells rsync to deliver the files in the current folder. Otherwise you could replace the dot (.) with a folder, say /home/foo/bar

  • 1
    The question specifically asks how to do this with scp. Since the other answers show that it is possible to do it in scp, there’s no need to present a solution using a different utility. You don’t offer any reason why an rsync solution is preferable, and what you do say is unclear. Jan 9, 2020 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.