Logged on as bryan@localserver, I'm trying to perform a backup using rsync on a remote host bryan@remoteserver.
I need the rsync connection to elevate privileges on the remote host using --rsync-path='sudo rsync'
, but I'm having problems, so have decided to simplify matters and just try to get the following working first:
bryan@localserver # ssh bryan@remoteserver 'sudo /usr/bin/whoami'
Once, I've cracked this, I should be able to get rsync working.
What I've done so far:
I've got ssh configured so that bryan@localserver can ssh to bryan@remoteserver using key instead of a password.
bryan@localserver # ssh bryan@remoteserver
bryan@remoteserver #
I've also configured bryan@remoteserver to be able to run /usr/bin/whoami
as sudo, without a password in the sudoers file on remoteserver:
bryan ALL=(ALL) NOPASSWD: /usr/bin/whoami
This works fine:
bryan@remotehost # sudo whoami
root
But from the local server:
bryan@localhost # ssh bryan@remoteserver 'sudo /usr/bin/whoami'
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
My complete sudoers file (minus the comments and blank lines) is below:
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults !requiretty
root ALL=(ALL:ALL) ALL
bryan ALL=(ALL) NOPASSWD: /usr/bin/whoami
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
ssh -t
from localserver solves the 'no tty present' error, but still prompts me for bryan@remotehost's password.
Can anyone please explain what the problem is?
localserver is Ubuntu 10.04 x64, remoteserver is Ubuntu 12.04 x64.
Best Answer
Are you a member of the
sudo
group oradmin
group? From thesudoers
man page:You can move your
bryan ALL=(ALL) NOPASSWD: /usr/bin/whoami
line to the bottom so it is the last match. This should keep you from being prompted for a password.