Skip to content

feat: add SSH agent auth and configurable sudo#13

Open
deevus wants to merge 1 commit intomainfrom
worktree-feat/ssh-agent-auth
Open

feat: add SSH agent auth and configurable sudo#13
deevus wants to merge 1 commit intomainfrom
worktree-feat/ssh-agent-auth

Conversation

@deevus
Copy link
Owner

@deevus deevus commented Feb 27, 2026

Summary

  • Add UseAgent and AgentSocket fields to SSHConfig for SSH agent authentication as an alternative to private key auth
  • Add NoSudo field to skip the sudo prefix when the SSH user can run midclt directly
  • Agent socket resolves from explicit config or SSH_AUTH_SOCK env var
  • UseAgent and PrivateKey are mutually exclusive (validated)

Based on work by @f33rx in deevus/terraform-provider-truenas#5.

Closes #5

Test plan

  • TestSSHConfig_Validate_AgentMode — valid agent config with explicit socket
  • TestSSHConfig_Validate_AgentAndPrivateKeyMutuallyExclusive — rejects both set
  • TestSSHConfig_Validate_AgentWithEnvSocket — falls back to SSH_AUTH_SOCK
  • TestSSHConfig_Validate_AgentNoSocketAvailable — errors with no socket
  • TestSSHConfig_Validate_PrivateKeyRequiredWithoutAgent — still requires key without agent
  • TestSSHClient_SudoPrefix_Default / _NoSudo — prefix behavior
  • TestSSHClient_Call_NoSudo — command string omits sudo
  • TestSSHClient_CallAndWait_NoSudo — same for job calls
  • All existing tests pass with race detector

🤖 Generated with Claude Code

Add UseAgent, AgentSocket, and NoSudo options to SSHConfig.
When UseAgent is true, authentication uses the SSH agent
(SSH_AUTH_SOCK) instead of a private key. NoSudo skips the
sudo prefix when the SSH user can run midclt directly.

Closes #5

Based on work by Dalton Perdue in deevus/terraform-provider-truenas#5.

Co-Authored-By: Dalton Perdue <dalton@perdue.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

⬇️ Go test coverage decreased from 86.4% to 86.3% compared to c25763d

Updated Package Coverages:

# Package Name                        |  Prior |    New
- github.com/deevus/truenas-go/client |  88.9% |  88.8%
View coverage for all packages
# Package Name                                   | Coverage
+ github.com/deevus/truenas-go                   |    83.2%
+ github.com/deevus/truenas-go/api               |    87.5%
+ github.com/deevus/truenas-go/client            |    88.8%
+ github.com/deevus/truenas-go/cmd/featurematrix |    92.9%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add SSH agent auth and configurable sudo

1 participant