polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie

I ran into this problem also and with some digging, found a working solution. 
The original solution is from this github issue for NixOS by EstalillaJ.

1. Open two ssh sessions to the target server.

2. In the first session, get the PID of bash by running:
	echo $$

3. In the second session, start the authentication agent with:
	pkttyagent --process (pid from step 2)

4. Back in the first session, run:
	pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
    
    or
    
    pkexec visudo

5. In the second session, you will get the password prompt. visudo will start 
in the first session.

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source