/ etc / sudoers文件损坏,我无法通过SSH运行“ pkexec visudo”


14

按照这里的说明我得到:

pkexec visudo

==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo' as the super user
Authenticating as: Thomas,,, (tuc) Password:  polkit-agent-helper-1:
error response to PolicyKit daemon:
GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for
cookie
==== AUTHENTICATION FAILED === 
Error executing command as another user: Not authorized

This incident has been reported.

我正在通过ssh进行此操作,因为我正在执行此操作的盒子被用作没有屏幕的音乐服务器,因此无法访问。我从Ubuntu 14.04升级到16.04时发生了这种情况。我试图从另一个最近的16.04安装中复制sudoers文件,但是由于sudoers文件而无法执行此操作:

sudo mv ~/gyrf sudoers

>> /etc/sudoers: syntax error near line 36 <<<
>> /etc/sudoers: syntax error near line 37 <<<
>> /etc/sudoers: syntax error near line 38 <<<
>> /etc/sudoers: syntax error near line 39 <<<
>> /etc/sudoers: syntax error near line 40 <<<
>> /etc/sudoers: syntax error near line 41 <<<
>> /etc/sudoers: syntax error near line 42 <<<
>> /etc/sudoers: syntax error near line 43 <<<
>> /etc/sudoers: syntax error near line 44 <<<
>> /etc/sudoers: syntax error near line 45 <<<
>> /etc/sudoers: syntax error near line 46 <<<
>> /etc/sudoers: syntax error near line 47 <<<
>> /etc/sudoers: syntax error near line 48 <<<
>> /etc/sudoers: syntax error near line 49 <<< 
sudo: parse error in /etc/sudoers near line 36    
sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin

我应该从阁楼上拿走盒子,然后尝试pkexec visudo还是这里出了点问题?


AFAIK pkexec仅允许本地用户(而不是SSH远程用户)这样做-是的,它应该在阁楼上工作
steeldriver

获取包装盒,或获取驱动器,将其安装在另一台计算机上,然后进行编辑sudoers以适应需要。取决于最简单的方法。
vidarlo

@steeldriverIt作为远程用户,它只是对我有用。JFYI。
php-coder

Answers:


44

我也遇到了这个问题,并进行了一些挖掘,找到了可行的解决方案。原始解决方案来自EstalillaJ针对NixOSgithub问题

  1. 打开两个到目标服务器的ssh会话。
  2. 在第一个会话中,通过运行以下命令获取bash的PID:

    echo $$

  3. 在第二个会话中,使用以下命令启动身份验证代理:

    pkttyagent --process (pid from step 2)

  4. 返回第一个会话,运行:

    pkexec visudo

  5. 在第二个会话中,您将看到密码提示。visudo将在第一个会话中启动。


5
伙计,你救了我的命!thx:D
罗杰·巴雷托

1
太疯狂了,它运作完美!无需重启系统
undefinedman,

1
多谢,这真的救了我!⭑–
弗雷德里克(Frederic)

1
从重新启动服务器到恢复过程中节省了我的**,非常高兴!
SergeantSerk,

1
那真是了不起的家伙!希望我也能喜欢答案!
阿德里安
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.