0

I am trying to set the scp as a specific user with NOPASSWD.

alice ALL = (bob:ALL) NOPASSWD: /usr/bin/scp

As I did understand from this question. However when I save using my visudo I still can't run sudo -u bob /usr/bin/scp bob@scp_client:upload_this_file.

What should be included within the command to allow no password scp for alice as bob (but not as root).

Note: I did see this, also I feel that everything is in the correct order in my sudoers file as I know about the order of commands like you can learn here.

The entire visudo file:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    mail_badpass
Defaults    insults
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification
    # Dropped this as it doesn't really matter..

# User alias specification
    # Dropped this as it doesn't really matter..

# Cmnd alias specification
    # Dropped this as it doesn't really matter..

# User privilege specification
root    ALL=(ALL:ALL) ALL

# We have admin groups (Todo: make this smaller)
%admin ALL=(ALL) ALL
%sudo   ALL=(ALL:ALL) ALL

# Include the sudoers.d
#includedir /etc/sudoers.d

# One to rule all of them
alice ALL = (bob:ALL) NOPASSWD: /usr/bin/scp
  • Are you sure the password being asked is by sudo and not by SSH? – muru Apr 1 '15 at 9:27
  • Yes I have passwordless SSH with both alice and bob. I have verified this with ssh alice@node ; ssh bob@node – Stolas Apr 1 '15 at 9:28
  • All that proves is that your current account has passwordless SSH, and says nothing about whether bob's account has passwordless SSH to bob's account on node. – muru Apr 1 '15 at 9:29
  • Indeed I stand corrected, I did the following: - As alice I did ssh bob@node - As alice I did sudo -s to get a rootshell, and promote myself to bob with sudo -u bob -s. - As bob I did ssh bob@node Works as expected. – Stolas Apr 1 '15 at 9:32
1

Managed to sudo -u bob -- ssh bob@node
Seems that sudo was passing the scp commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.