diff options
| author | Shulhan <ms@kilabit.info> | 2021-11-06 15:50:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-11-06 15:50:50 +0700 |
| commit | a4e9ce624b7664f8f5e7b12839d2d5d812691125 (patch) | |
| tree | 7c1572b0bde62d51a6d020f02925a8554e8dfad8 /lib/ssh/client.go | |
| parent | fea93ff9064c4d4b8cef743240c2720ad61f108e (diff) | |
| download | pakakeh.go-a4e9ce624b7664f8f5e7b12839d2d5d812691125.tar.xz | |
lib/ssh: use agent defined by config or from environment variable
Previously, we only check the environment variable SSH_AUTH_SOCK
to decide whether the client identity will fetched from agent or
from private key file.
This changes use the GetIdentityAgent from config Section to derive the
path to unix socket. It will return an empty string if the IdentityAgent
is set to "none" in the Section or when SSH_AUTH_SOCK is not exist or
empty.
Diffstat (limited to 'lib/ssh/client.go')
| -rw-r--r-- | lib/ssh/client.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ssh/client.go b/lib/ssh/client.go index 7deaefee..dc13300a 100644 --- a/lib/ssh/client.go +++ b/lib/ssh/client.go @@ -45,7 +45,7 @@ func NewClientFromConfig(cfg *config.Section) (cl *Client, err error) { HostKeyCallback: ssh.InsecureIgnoreHostKey(), } - sshAgentSockPath := os.Getenv("SSH_AUTH_SOCK") + sshAgentSockPath := cfg.GetIdentityAgent() if len(sshAgentSockPath) > 0 { sshAgentSock, err := net.Dial("unix", sshAgentSockPath) if err != nil { |
