Tag Info

Hot answers tagged

5

The error message tells you what is wrong even if it doesn't tell you exactly how to fix it. adminvpn is not in the sudoers file. sudo lets you run commands as the administrator. In order to be able to use sudo, you need to be made an administrator. Accounts are not made administrators by default. Run the command visudo (as root, of course) and add a ...


2

You could use the python script thefuck available on github. This script is designed to correct the last command you ran incorrectly for a few use cases and forgetting to use sudo is one of them. From their examples: ➜ apt-get install vim E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration ...


2

When commands are run they split into a child processes, so when the 'su' command runs it's going to run in a separate process to the cp command and not actually within the root terminal. The command will work if you run cp with sudo, but it's not going to run inside the root terminal, you'd have to run the commands separately within su to accomplish that. ...


2

I suspect there's no myip recorded in /root/.ssh/known_hosts. Please try once sudo ssh root@myip interactively before running that script. Alternatively, you can disable host key checking: #!/bin/bash -v sshpass -p '<pypasswd>' scp -o StrictHostKeyChecking=no blah.img root@myip:/home/user/blah.img exit 0


2

I'd personally make no assumption on sudo, just as putting sudo in a script is a bad idea. Your fourth suggestion (check whether the script runs as root) is best, IMHO. Just that I prefer checking the effective user ID instead of its name: [ -n "$EUID" ] && [ $EUID -eq 0 ] || <not root, exit> This will leave the choice to the user, which ...


1

Eplanation for %sudo ALL=(ALL:ALL) ALL:- %sudo - the group (named sudo) allowed to use sudo. 1st ALL means to allow sudo from any terminal, or from any host (on any machine) (ALL:ALL) indicates command can be run as (User:Group) Last All means all commands can be executed Explanation for root ALL=(ALL) ALL root - the user (root) allowed to do ...


1

sudo su && cp /home/sk/keys/master.pem /home/sg-user/keys/ This runs the command sudo su. sudo su runs an interactive shell as root, it is basically equivalent to sudo -s or sudo bash (if your shell is bash). Once this command has finished, if it returned a success status, the cp command is executed as the original user. As far as the shell is ...


1

Your root user doesn't have the same private keys that you are using when not running as root. Therefore, as root, you cannot copy the material. Try copying adding ~/.ssh/id_rsa to /root/.ssh/id_rsa (or some other private key you are using to connect to myip). Alternatively let the sudo do the other things, and change back to the "normal" user in the ...


1

It is possible using sudo. Use %<group-name> for the RunAs list. For example, with the following rule: sysad ALL = (%wheel) ALL And the following group configuration: $ getent group wheel wheel:x:10:root,muru We get the following amusing effect: $ sudo -u sysad bash -c 'echo $USER' Sorry, user sysad is not allowed to execute '/usr/bin/bash' as ...


1

What did you use to create the user? My preliminary test shows that a simple useradd <login> visudo # in visudo <login> ALL=(ALL) NOPASSWD: ALL # save and exit visudo # as another user $ sudo -u <login> hostname -f $ sudo -u <login> -s Should work without any further problems, what does the asterisk log tells you ? Did you by ...


1

You should try sudo cp /home/sk/keys/master.pem /home/sg-user/keys/


1

This is probably doable with an SELinux policy (and probably not doable without SELinux or other a security module that can confine root), but it's pointless. As you note, a package could declare that it installs /etc/sudoers. Even if you make an ad hoc rule to somehow prevent that, the package could drop a file in /etc/sudoers.d. Or it could drop a file in ...


1

If a user can create any package and upload it to a repository trusted by the installer, I don't know of any way to protect the system in the way you're looking for (at least not with apt-get). Maintainer scripts in a package are run as root (whether on apt, yum or dnf type systems), so installing a package effectively gives the package's author root access ...


1

winbind and sssd import the AD groups in an equivalent manner to NIS netgroups. So your group definitions in the /etc/sudoers file need to start with + and not %. Furthermore, names containing spaces should either be double-quoted, or each space specified as \x20. %sudo ALL = (ALL) ALL +"domain users" ALL = (ALL) ALL +domain\x20admins ALL = ...


1

Several months after you asked but the correct answer is that you remove all domain information from the group. All the information is set and extracted by SSSD automatically. The only flaw I see in some of your examples is that you escaped the space with a ^. An AD group of Enterprise Admins would have a sudoers line that starts with %Enterpirse\ Admins ...


1

Quick answer: Install bash-completion Source bash_completion on Bash startup Add your compspec on Bash startup Don't overwrite sudo compspec with complete -cf sudo I suppose that you use MacOSX with brew. Try: brew update brew install bash-completion brew info bash-completion # bash-completion: stable 1.3 . $(brew --prefix)/etc/bash_completion complete ...


1

I tend to use:sudo su - USERNAME and then do what you need as that user. To quit just type exit


1

In some distros, Manjaro in my case, there is a file that overrides the /etc/sudoers file sudo cat /etc/sudoers.d/10-installer the ONLY way to see it is under root privilegies, you cannot list this directory without it. There you will find something like this: youruser ALL=(ALL) You can delete that file, and will use cfg in /etc/sudoers file ...



Only top voted, non community-wiki answers of a minimum length are eligible