Skip to content

Commit c634cba

Browse files
committed
fix: only force IdentityAgent when required
1 parent 9d05b7b commit c634cba

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ func processCommand() int {
111111
// override default ssh-agent socket
112112
os.Setenv("SSH_AUTH_SOCK", agent.SocketFile())
113113
log.Debugf("set SSH_AUTH_SOCK to %q\n", agent.SocketFile())
114-
sshClient.PrependArgs([]string{"-o", "IdentityAgent=SSH_AUTH_SOCK"})
114+
if sshClient.ForceIdentityAgent {
115+
sshClient.PrependArgs([]string{"-o", "IdentityAgent=SSH_AUTH_SOCK"})
116+
}
115117

116118
case "sign":
117119
signedKey, err := vaultClient.SignKey(sshClient.User)

openssh/openssh.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import (
1515
)
1616

1717
type Client struct {
18-
Args []string
19-
HostConfig []string
20-
User string
21-
Hostname string
22-
Extensions Extensions
23-
CertificateString string
24-
CertificateFile string
25-
CertificateObject *ssh.Certificate
18+
Args []string
19+
HostConfig []string
20+
User string
21+
Hostname string
22+
Extensions Extensions
23+
CertificateString string
24+
CertificateFile string
25+
CertificateObject *ssh.Certificate
26+
ForceIdentityAgent bool
2627
}
2728

2829
// Options for https://man.openbsd.org/ssh.1; parsed simply to provide accurate Destination and RemoteCommand
@@ -127,6 +128,8 @@ func (c *Client) ParseConfig() error {
127128
if value == "yes" {
128129
c.Extensions.X11Forwarding = true
129130
}
131+
case "identityagent":
132+
c.ForceIdentityAgent = true
130133
case "localforward":
131134
c.Extensions.PortForwarding = true
132135
case "remoteforward":

0 commit comments

Comments
 (0)