6

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

If I ssh with 1, then sudo 2 I can browse them.

What I want actually is a mirror to copy them over to my Windows-based PC

How can I achieve that if only SSH is available?

1
  • Do you mean sudo su 2?
    – maco
    Oct 22 '10 at 21:36
5

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.

4

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'.

2

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.

1
  • 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
1

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

Their site has instructions on su-ing to another user after logon: http://winscp.net/eng/docs/faq_su

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.