feat: 增强 ssh-agent 认证与转发可靠性
- 拆分 ssh-agent 认证、连接与 endpoint 解析逻辑 - 新增 IdentityAgent、SSHAgentTimeout、SSHAgentForwardTimeout 和调试事件 - 为 agent list/sign 操作增加独立 deadline,避免硬件 agent 卡死登录 - 支持 agent signer 失败后跳过坏 key 并重试后续 key - 优先处理 RSA-SHA2 签名,兼容现代 OpenSSH 认证要求 - 增强 agent forwarding 的探测、通道空闲超时和关闭清理 - 补充 Windows OpenSSH pipe 与 GPG S.gpg-agent.ssh socket 文件支持 - 增加相关回归测试和 Windows 编译验证覆盖
This commit is contained in:
+10
-7
@@ -4,16 +4,19 @@ package starssh
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func dialSSHAgent(timeout time.Duration) (net.Conn, error) {
|
||||
agentSock := strings.TrimSpace(os.Getenv("SSH_AUTH_SOCK"))
|
||||
if agentSock == "" {
|
||||
return nil, errSSHAgentUnavailable
|
||||
}
|
||||
func defaultSSHAgentEndpoint() (resolvedSSHAgentEndpoint, error) {
|
||||
return resolvedSSHAgentEndpoint{}, errSSHAgentUnavailable
|
||||
}
|
||||
|
||||
func defaultSSHAgentNetwork(endpoint string) string {
|
||||
return "unix"
|
||||
}
|
||||
|
||||
func dialResolvedSSHAgent(resolved resolvedSSHAgentEndpoint, timeout time.Duration) (net.Conn, error) {
|
||||
agentSock := resolved.Endpoint
|
||||
if timeout > 0 {
|
||||
return net.DialTimeout("unix", agentSock, timeout)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user