1

I keep seeing this whenever enter sudo on different user than ubuntu

You must SSH in as root to run this command: sudo

Here is the output of sudo -l -U myuser

Matching Defaults entries for serverpilot on ubuntu-xenial:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User myuser may run the following commands on ubuntu-xenial:
    (ALL) NOPASSWD: ALL

I added myuser to /etc/sudoers.d/90-cloud-init-user I'm using Vagrant to manage my machines.

P/s: Before I posted this, I'm still able to add new sudo user by above way without any problems. (Previous ubuntu boxes version)

2
  • Are you running a restricted shell or something?
    – muru
    May 19, 2017 at 8:38
  • @muru No I didn't. The only way to get move on is set env bash inside .bash_profile. Is that make any sense to you? Because I never seen this before... Nov 8, 2017 at 6:23

1 Answer 1

0

Serverpilot is doing this deliberately for unknown reasons. It doesn't actually prevent use of sudo which you can verify with which sudo

/usr/bin/sudo

and if you call sudo with full path it works fine. e.g.

/usr/bin/sudo whoami

an alias is being set in

/etc/profile.d/serverpilot-aliases.sh

if [[ "$HOME" == /srv/users/* ]]; then
   alias sudo='echo "You must SSH in as "root" to run this command: sudo"'
fi

you can confirm with alias

alias sudo='echo "You must SSH in as "root" to run this command: sudo"'

You can fix it temporarily with

unalias sudo

Serverpilot would need to show up and account for their weird decision. You can fix permanently by removing that alias declaration from the file listed. Doing so may have unknown and unintended effects on serverpilot. Surely they did it for a reason...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .