Remote root ssh

Smoot Carl-Mitchell smoot at tic.com
Mon Jun 25 20:51:38 UTC 2007


On Mon, 2007-06-25 at 11:24 -0400, fletcher johnson wrote:
> Hello, I'm trying to ssh remotely into my ubuntu box as root and
> transfer files. How can I do this without enabling root (Let's use
> sudo only)? 
> Basically something like this. scp
> user at 192.168.1.103:/home/user at user/somefile_with_root_perms . 
> Thanks!

Something like this will work:

ssh -t user at 192.168.1.103 sudo scp <source> <target>

You need the -t to force a tty to be allocated so you can be prompted
for the password for the sudo when prompted and also for the scp if it
needs password authentication.

Watch out for shell expansion issues when you do this. If you have
characters which are interpreted by the local shell, then it is best to
quote the entire remote command. e.g.

ssh -t user at 192.168.1.103 'sudo scp <source> <target>'

Any special shell characters within the single quoted command string
will be interpreted by the remote shell (the one on 192.168.1.103) and
not by the local shell.
-- 
Smoot Carl-Mitchell
System/Network Architect
email: smoot at tic.com
cell: +1 602 421 9005
home: +1 480 922 7313




More information about the ubuntu-users mailing list