Hi,

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

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

jlams...@ubuntu1:~$ touch file.txt

1.) This works, because I can write to /tmp
jlams...@ubuntu1:~$ scp file.txt [email protected]:/tmp
[email protected]'s password:
file.txt 100% 0 0.0KB/s 00:00
2.) This works, because I use sudo
jlams...@ubuntu1:~$ ssh [email protected] 'sudo touch /root/file.txt'
[email protected]'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:
jlams...@ubuntu1:~$ scp file.txt [email protected]:/root/
[email protected]'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 via email to