AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题

问题[sudoers](computer)

Martin Hope
Daniel McLaury
Asked: 2022-07-28 05:52:50 +0800 CST

为什么 `sudo` 和 `sudo -i` 对待 NOPASSWD 的方式不同?

  • 5

我有一个帐户需要无缝伪装成其他帐户,如下所示:

manager$ sudo -u worker_A echo hello from worker A
hello from worker A
manager$ sudo -u worker_B echo hello from worker B
hello from worker B

所以我把这样的东西放在一个文件中/etc/sudoers.d:

manager ALL=worker_A,worker_B,worker_C NOPASSWD: ALL

这似乎适用于上述命令。但是,在某些情况下,我需要作为worker_*帐户做的事情需要整个登录环境,即我需要将-i/--login标志传递给 sudo。然而,当我尝试这个时,我得到了一个完全出乎意料的结果:

manager$ sudo -u worker_A echo hello from worker A
hello from worker A
manager$ sudo -u worker_A -i echo hello from worker A
[sudo] password for manager:

问题:

  • 这里发生了什么?
  • 我该如何解决?

(注意:我已经更改了帐户名称并简化了 sudoers 文件的内容,以创建一个最小的示例并保护隐私。希望我没有在此过程中无意中输入任何拼写错误或更改任何内容。)

sudo sudoers
  • 1 个回答
  • 42 Views
Martin Hope
Yanick Rochon
Asked: 2020-11-14 06:54:45 +0800 CST

Debian 10 上的 sudoers 文件在哪里?

  • 8

有一个服务器是前段时间设置的,我需要更改一些设置,其中一个是具有超级用户权限的用户。但是,我看到的任何地方都告诉我使用visudo或编辑/etc/sudoers,但是这台服务器上不存在这些东西。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
$ whereis visudo
visudo:
$ visudo
-bash: visudo: command not found
$ ls -l /etc/sudoers
ls: cannot access '/etc/sudoers': No such file or directory

该配置在哪里?

** 编辑 **

需要明确的是,用户可以su在没有密码的情况下进行设置,但由于/etc/sudoers不存在visudo且未安装(也没有sudo),那么该配置在哪里?

debian sudoers
  • 2 个回答
  • 1064 Views
Martin Hope
j4nd3r53n
Asked: 2020-10-01 02:33:38 +0800 CST

让单个用户在没有 sudo 密码的情况下执行命令

  • 5

我已经搜索并找到了很多答案,但我仍然无法让它工作。这是在 debian 9 系统上 - 我在配置文件中创建了一个别名和一个 shell 函数:

alias lscron='sudo crontab -u biuser -l'

function edcron
{
  lckf=~biuser/edcron
  if [[ -f $lckf ]]
  then
    echo $(cat $lckf) is editing
  else
    echo $(id -nu) > $lckf
    sudo crontab -u biuser -e
    rm $lckf
  fi
}

它们按预期工作,但要求输入密码。我想让一些用户无需密码即可运行这些命令,所以我添加了如下内容/etc/sudoers:

analytics root = cat /etc/sudoers
#
# 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        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

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

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

some.user ALL = NOPASSWD: /usr/bin/crontab -u biuser -e, /usr/bin/crontab -u biuser -l

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

我没有收到任何错误,但它要求输入密码;我如何让它工作?

编辑

Matching Defaults entries for some.user on analytics:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User some.user may run the following commands on analytics:
    (ALL : ALL) ALL
    (root) NOPASSWD: /usr/bin/crontab -u biuser -e, /usr/bin/crontab -u biuser -l
    (ALL : ALL) ALL
sudo sudoers
  • 1 个回答
  • 164 Views
Martin Hope
ul.Duc
Asked: 2020-02-19 05:39:28 +0800 CST

已解决 - 使用 rundeck sudo 进入用户而不是 root

  • 5

我正在为 Centos7 上的一些生物信息分析配置服务器,并且我安装了 rundeck。Rundeck 似乎将脚本作为自己的帐户名启动,我决定使用 sudo 绕过来使其访问我的脚本。

使用 visudo 我可以使 sudo 与 rundeck 更改为 root 有一些没有密码的命令。一旦我输入用户 bioinfo 而不是 root,系统就会要求输入相同命令的密码。

这是 sudoers 文件的一部分:

root    ALL=(ALL)       ALL
bioinfo ALL=(ALL)       ALL
rundeck ALL=(bioinfo)      NOPASSWD:/home/bioinfo/singularity_data/Bionano3.5,/usr/local/bin/singularity,/bin/*

我不知道 root 和 bioinfo 之间有什么不同,因为它们具有相同的权利。有没有人知道当它与 root 一起工作时,什么会导致它不能与 bioinfo 一起工作?

我尝试以 root 身份运行我的配置

su - rundeck

然后做一个

sudo whoami

if root => root
if bioinfo => 询问密码

谢谢

sudo sudoers
  • 1 个回答
  • 2049 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve