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

I ssh into a ubuntu box with username "ubuntu" and I can become root without entering a password via "sudo su". How can I scp files onto this box using the ubuntu@ username? It does not allow me to do so using root@. The error is:

scp: /etc/...: Permission denied

I can do this same task in rsync by using --rsync-path="sudo rsync" for example.

share|improve this question

migrated from Feb 5 '10 at 1:01

This question came from our site for professional and enthusiast programmers.

You might want to post this on instead - that's just like Stack Overflow but precisely for answering this sort of question - you'll get a better response there than here. – user26996 Feb 4 '10 at 20:34

As you suggested, use rsync with the sudo trick. scp won't preserve permissions anyway.

share|improve this answer

You can either SCP them as the user and then log in and copy them as root. Since SCP can't su, there's not a good way to do it unless you change root's password.

(I thought you would have to add PermitRootLogin yes to /etc/sshd/sshd.cofig, but it seems Ubuntu uses the random-root-password method instead of locking out root)

share|improve this answer

You must log in to answer this question.