0

I have this linux machine with ssh server installed, I can access the server using username="ubuntu". ssh server blocks clients that try to connect using "root" username.

So connection can be made by:

ssh -i mykey ubuntu@myserver

I can get files that belong to "ubuntu" using :

scp -i mykey ubuntu@myserver:<file location> ./

However, what I really want is to get files that belong to "root" username, (Note: I can't access the server with username "root" for obvious security reasons).

so is there a way to do download files that are under "root" username?

I was thinking to do some magic in the server side that enables me to do that.(I don't know how :) )

if this help: I have root access and also I can create files on my server side. but I'm not allowed to change the file permission under the root(if someone get hold of these files I'll be fired)

nafas
  • 5,283
  • 3
  • 29
  • 57

3 Answers3

1

You can try monster like this

ssh ubuntu@myhost 'sudo cat /path/to/file | uuencode' | uudecode > path/to/local

You should have uuencode and uudecode on coresponding hosts.

Or if file is text you can skip uuencode part

ps: see related topic

Community
  • 1
  • 1
talex
  • 17,973
  • 3
  • 29
  • 66
  • I tried this code, it gets stuck for some reason. instead of using "su" I use "sudo su". could that be a problem? – nafas Aug 22 '14 at 14:58
  • It probably wait for password. Try to find options to pass password as parameter to `su` – talex Aug 22 '14 at 15:00
  • I just changed the code to 'sudo cat /path/to/file' and it worked. (since only text files are copied I didn't used uuencode). thx mate, it helped alot. could you just change the code so I can tick it as answered – nafas Aug 22 '14 at 15:04
  • I changed my sampe. But for other people it may need another way to get required permission. – talex Aug 25 '14 at 08:02
0

You could do it the other way around.

Log into the the pc with the file you want with

ssh ubuntu@myserver

Then gain superuser privileges

sudu su

and then copy the files you want

scp /the_file_you_want ubuntu@myhost:/the_location_and_filename_you_want

Some other ways you can find here https://unix.stackexchange.com/questions/106480/how-to-copy-files-from-one-machine-to-another-using-ssh

Community
  • 1
  • 1
mcdikki
  • 109
  • 4
  • The problem is my local machine is not accessible via ssh. (its not a server) – nafas Aug 22 '14 at 13:42
  • Ah, ok. So thats what I put the link in for. There you find some interesting ways to use tar for doing this without scp but only ssh – mcdikki Aug 22 '14 at 13:47
0

enable ssh on your machine (if fedora) (for ubuntu you can find command on google easily)

 service sshd on

From your local machine

 ssh -i ubuntu@myserver

change to root

su

enter password

and copy files using scp

scp somefile.extension randomuser@localmachine:/some/path/

I hope it helps

John F
  • 99
  • 7
  • that's the problem, I'm not able to enable ssh server on my local machine. its a windows machine under company's router. so there absolutely no way) – nafas Aug 22 '14 at 13:50