Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 have access to a box over ssh and there are some files i'd like to transfer to another machine, but those are only accessible under another account

so if i ssh with 1, then sudo 2 i can browse them

what i want actually is mirror copy them over to my windows based pc how can i achieve that if only ssh is available.

share|improve this question
Do you mean sudo su 2? – maco Oct 22 '10 at 21:36
up vote 2 down vote accepted

I assume that you do not have the password to the other user account, nor to the root account, and/or the remote host does not allow direct root login via SSH.

If it is not too much data, I would just SSH in beforehand, become root, create a tarball of the data, grant access to the tarball for your regular user, then download the tarball as your regular user.

share|improve this answer
is there an easier way of doing this yet? I want to copy files I only have sudo permissions to but taring them every time isn't fun. Is there really no way to scp as sudo on remote host? – waspinator Feb 7 '12 at 17:05

You can, using scp. It's done like this:

scp <file to transfer> user@server:/place/to/put/file

scp is provided by ssh in the package openssh-client

For more info, type 'man scp'.

share|improve this answer

You can use something like tar to and pipes to do this (as long as you have tar available on both hosts). For example, to copy root's homedir over to another host:

sudo tar c -C / root | ssh remote_host tar xv -C some/location/to/unpack/into

(assuming gnu tar for -C support, it can be done without it using '()' but it's trickier) and of course, you can do the sudo on the remote end:

tar c -C my_trojan_files . | ssh remote_host sudo tar xv -C /usr/bin

The trick here is that, in both cases, tar is emitting the archive to STDOUT, which is being piped into the command running on the remote host via ssh. You can do this with cpio and dump/restore as well.

share|improve this answer

You can install winscp on your Windows box to pull the files from your Ubuntu machine over ssh.

Their site has instructions on su-ing to another user after logon:

share|improve this answer

Your Answer


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

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