Search: Home Bugtraq Vulnerabilities Mailing Lists Jobs Tools Beta Programs
Secure Shell
remote scp command Sep 25 2009 10:51AM
Jurgen Lamsens (jurgen lamsens telenet be) (2 replies)
Re: remote scp command Sep 25 2009 08:56PM
Greg Wooledge (wooledg eeg ccf org)
RE: remote scp command Sep 25 2009 02:02PM
Males, Jess (jmales cio sc gov)
Jurgen,

Thanks for asking. Initially, I wanted to say, "not possible," but then I considered the form of your question and realized that there was a way.

date | ssh localhost 'sudo sh -c "/bin/cat > /etc/tmp"'

The core of this is that you can pipe into ssh and it'll connect it through the session. I'd seen this in examples for tarring files across an ssh session for file transfers; never really used it.

The nasty bit is, as I have it, I had to add sh to the sudo file. Ok, nasty is an understatement, this is detestable; don't do it. For your solution, you'll probably want to write a little script that just does, "cat > $file", and add the script to /etc/sudoers.

The input redirection isn't interpreted as part of the sudo command; it's still the local account, thus the small script or sh -c wrapper. If there's a better way around this, please share.

I also had issue with typing the password for the sudo, so I just used nopasswd for the test.

so, your file transfer should be something like (not tested):

cat /path/to/source | ssh host "sudo dump.sh"

dump.sh:
#!/bin/sh
cat > $1

-- Jess Males

-----Original Message-----
From: listbounce (at) securityfocus (dot) com [email concealed] [mailto:listbounce (at) securityfocus (dot) com [email concealed]] On Behalf Of Jurgen Lamsens
Sent: Friday, September 25, 2009 6:52 AM
To: secureshell (at) securityfocus (dot) com [email concealed]
Subject: remote scp command

Hi,

I hope I'm at the right place for my question. Consider this:

jlamsens@ubuntu1:~$ cat /etc/hosts
127.0.0.1 localhost
192.168.155.186 ubuntu1
192.168.155.187 ubuntu2

jlamsens@ubuntu1:~$ touch file.txt

1.) This works, because I can write to /tmp
jlamsens@ubuntu1:~$ scp file.txt jlamsens (at) 192.168.155 (dot) 187 [email concealed]:/tmp
jlamsens (at) 192.168.155 (dot) 187 [email concealed]'s password:
file.txt
100% 0 0.0KB/s 00:00

2.) This works, because I use sudo
jlamsens@ubuntu1:~$ ssh jlamsens (at) 192.168.155 (dot) 187 [email concealed] 'sudo touch /root/file.txt'
jlamsens (at) 192.168.155 (dot) 187 [email concealed]'s password:

3.) I want to scp to a directory that I do not have access to, but I
cannot give some kind of sudo parameter to scp:
jlamsens@ubuntu1:~$ scp file.txt jlamsens (at) 192.168.155 (dot) 187 [email concealed]:/root/
jlamsens (at) 192.168.155 (dot) 187 [email concealed]'s password:
scp: /root//file.txt: Permission denied

How can I make the last one work in one shot, knowing that I can use
sudo in step 2.)
-> I don't want to login to ubuntu2, and do the scp the other way arount
-> I don't want to scp to e.g. ubuntu2:/tmp first, login to ubunt2 and
move from ubuntu2:/tmp to ubuntu2:/root

Thanks in advance,
Kind regards,
Jurgen Lamsens

[ reply ]







 

Privacy Statement
Copyright 2009, SecurityFocus