sudo-ssh-auth
Skill1 starsChanged 4 days agoMITView on GitHub
Enable sudo authentication via a forwarded SSH agent, including Cursor.
- Reads credentials
- Installs packages
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- broSkill
- create-my-skillSkill
- glassmorphismSkill
- swiftui-designSkill
- humanizerSkill
- ponytail-auditSkill
- ponytail-debtSkill
- ponytail-gainSkill
- ponytail-helpSkill
- ponytail-reviewSkill
- ponytailSkill
- clean-up-git-historySkill
- commit-msgSkill
- diagnoseSkill
- fixSkill
- grill-meSkill
- implementSkill
- loopSkill
- subagentsSkill
- update-docsSkill
- verify-appSkill
- web-app-secSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Keep fs.protected_symlinks enabled and retain SSH-agent authentication rather than adding NOPASSWD.
- Very specific: line 83
Verify /usr/local/bin precedes /usr/bin in the intended user's and Cursor agent's actual PATH.
- Distinctive: line 87
Verify as the intended non-root user, both in a fresh terminal and through the Cursor agent when it is part of the task.
- Distinctive: line 93
If agent execution cannot be invoked from the current tools, request a targeted check from that agent and distinguish it from tests …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add sudo SSH auth sock
Cursor sets SSH_AUTH_SOCK to a user-owned symlink in sticky /tmp and retargets it on reconnect. With fs.protected_symlinks=1, root cannot follow that link, so pam_ssh_agent_auth fails.
Install a root-owned executable wrapper at /usr/local/bin/sudo. It resolves the link as the invoking user, then executes the real sudo with the resolved path. Resolve it on every invocation so reconnects keep working; leave the parent shell's SSH_AUTH_SOCK unchanged.
Keep fs.protected_symlinks enabled and retain SSH-agent authentication rather than adding NOPASSWD.
Steps
Install the
pam_ssh_agent_authmodule. Skip if it is already installed.Debian/Ubuntu:
apt-get install -y libpam-ssh-agent-authRHEL/Fedora:
dnf install -y pam_ssh_agent_authEnable the module before the common auth include in
/etc/pam.d/sudo, if it is not there yet. On RHEL-family systems the include line isauth include system-auth. The sed regex already handles both.%hmakes the module trust the invoking user's own~/.ssh/authorized_keys; preserve an existingfile=or authorized-keys command instead of replacing its key policy. Before the edit, copy the file to/etc/pam.d/sudo.bakif that backup does not exist yet. After the edit, verify the module was actually inserted before password authentication. If the auth stack differs from these patterns, adapt to the actual file. If the result looks wrong, restore from the backup.grep -q pam_ssh_agent_auth /etc/pam.d/sudo || { [ -f /etc/pam.d/sudo.bak ] || cp /etc/pam.d/sudo /etc/pam.d/sudo.bak sed -i \ -E '0,/^(@include[[:space:]]+common-auth|auth[[:space:]]+include[[:space:]]+system-auth)/s||auth sufficient pam_ssh_agent_auth.so file=%h/.ssh/authorized_keys\n&|' \ /etc/pam.d/sudo } grep pam_ssh_agent_auth /etc/pam.d/sudosudo -iuses/etc/pam.d/sudo-i. If that file has its ownauthstack instead of includingsudo, back it up to/etc/pam.d/sudo-i.bakif that backup does not exist yet, then insert the samepam_ssh_agent_authline before its firstauthline, keeping any existingfile=policy.grep -Eq '^(@include|auth[[:space:]]+include)[[:space:]]+sudo$' /etc/pam.d/sudo-i 2>/dev/null || grep -q pam_ssh_agent_auth /etc/pam.d/sudo-i 2>/dev/null || [ ! -f /etc/pam.d/sudo-i ] || { [ -f /etc/pam.d/sudo-i.bak ] || cp /etc/pam.d/sudo-i /etc/pam.d/sudo-i.bak sed -i \ -E '0,/^auth/s||auth sufficient pam_ssh_agent_auth.so file=%h/.ssh/authorized_keys\n&|' \ /etc/pam.d/sudo-i } cat /etc/pam.d/sudo-iAdd
Defaults env_keep += "SSH_AUTH_SOCK"to/etc/sudoers.d/ssh-auth-sockwith mode0440. If the directive already applies in/etc/sudoersor/etc/sudoers.d/, skip the step. Inspect an existing file before editing; preserve unrelated rules. Validate the snippet and full configuration withvisudo -cfand restore the previous content if validation fails. This configures authentication; the user still needs sudo permission.cat > /etc/sudoers.d/ssh-auth-sock << 'EOF' Defaults env_keep += "SSH_AUTH_SOCK" EOF chown root:root /etc/sudoers.d/ssh-auth-sock chmod 0440 /etc/sudoers.d/ssh-auth-sock visudo -cf /etc/sudoers.d/ssh-auth-sock visudo -cf /etc/sudoersVerify that
/usr/bin/sudois the real sudo executable and/usr/bin/readlinksupports-f. Adapt the absolute paths below if the host differs; never locate sudo throughPATHfrom inside its wrapper. Inspect/usr/local/bin/sudofirst: skip an identical wrapper and preserve or adapt any unrelated existing implementation. Create the wrapper as root, owned byroot:rootwith mode0755, without a setuid bit.cat > /usr/local/bin/sudo << 'EOF' #!/bin/sh if [ -L "${SSH_AUTH_SOCK:-}" ]; then SSH_AUTH_SOCK=$(/usr/bin/readlink -f -- "$SSH_AUTH_SOCK") || exit 1 export SSH_AUTH_SOCK fi exec /usr/bin/sudo "$@" EOF chown root:root /usr/local/bin/sudo chmod 0755 /usr/local/bin/sudo- Verify
/usr/local/binprecedes/usr/binin the intended user's and Cursor agent's actualPATH. If it does not, fix the environment that launches that session. Explicit/usr/bin/sudocalls bypass the wrapper; report this limit. Do not replace the distribution's sudo binary.
Verify
Verify as the intended non-root user, both in a fresh terminal and through the Cursor agent when it is part of the task. A root session or a cached sudo timestamp does not prove authentication works.
command -v sudoresolves to/usr/local/bin/sudo.sudo -k idauthenticates through the SSH agent and returnsuid=0(root)without a password. Corroborate with the PAM authentication log. If the runner requires non-interactive input, use a supported invocation that still attempts PAM authentication;sudo -nalone can refuse before PAM runs.sudo -k -i idalso authenticates through the SSH agent without a password.- The parent shell's
SSH_AUTH_SOCKremains the Cursor symlink, whilesudo printenv SSH_AUTH_SOCKshows its resolved target. - If agent execution cannot be invoked from the current tools, request a targeted check from that agent and distinguish it from tests performed through SSH.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

