Using Commands over SSH using Sudo
Is there a way to transfer my sudo password via ssh so that I can copy files remotely and pass them locally, so:
Code:
cat sudo-passwd-file|ssh -t user@10.7.0.180 'sudo find / -depth|cpio -oacv|gzip' > /path/to/dir/file.cpio.gz Code:
cat passwd-file|ssh -t saint@10.7.0.180 'sudo find / -depth' |
@ Reply
Hi metallica1973,
Isn't the easy way would be setting up key based authentication for that particular user and let it run commands on the remote server? You can refer following link that will help you out: http://linuxproblem.org/art_9.html The reason I am suggesting this because it is more secure than keeping your password in a file (plain-text) |
I appoligize for not clarifying my setup. I do use "hostbasedauthentication" and currently use passwordless ssh commands to do other stuff like:
example: Code:
ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l user 10.7.0.180 "find / -depth|cpio -oacv|gzip" > /path/to/dir/file.cpio.gz |
Couldnt I just:
connect to 10.7.0.180 and add a newline or edit existing to look like Code:
|
@ Reply
Yes, you can do that. However, it should look like as follows instead:
Code:
user ALL=NOPASSWD: /usr/bin/find Below syntax doesn't look correct to me. Code:
user ALL=(ALL) NOPASSWD: /usr/bin/find |
Many thanks for the reply. I made the correction made it specific to a user:
Code:
user ALL=NOPASSWD: /usr/bin/find, /bin/cpio, /bin/gzip Code:
ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l user 10.7.0.180 "find / -depth|cpio -oacv|gzip" > /path/to/dir/file.cpio.gz Code:
cpio: /etc/ConsoleKit/seats.d/00-primary.seat: Cannot utime: Operation not permitted |
@ Reply
Are you trying to say when you ssh using the user account user to other servers it works fine with sudo. However, it does not work on this particular server? If yes, then check the permission that this account has got on this server. Appears to be a file system permission issue to me.
|
It does appear to be an permission issue.
Regards |
I had a senior moment and I realized that I wasnt using sudo in my statement so when testing I ran into some issues. Here is my testing scenario.
/etc/sudoers Code:
user ALL=NOPASSWD: /usr/bin/find, /bin/cpio, /bin/gzip Code:
Code:
|
I even changed
/etc/sudoers Code:
user ALL = NOPASSWD: ALL Code:
user@mymachine:~$ ssh -t -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l user 10.7.0.180 "sudo find / -depth" Code:
ssh -t -t -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l user 10.7.0.180 |
It definately has to due with what I have inside of the sudoers file:
Code:
ssh -t -t -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l user 10.7.0.180 |
It was in fact /etc/sudoers and the placement of my entry, so from:
Code:
root ALL=(ALL) ALL Code:
http://askubuntu.com/questions/10005...on-not-working solved!!!! |
All times are GMT -5. The time now is 10:53 AM. |