Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: fail open for connect to local ssh agent (#5999)
h3n4l78c2e4b0586b
diff --git a/backend/plugin/db/util/ssh.go b/backend/plugin/db/util/ssh.goindex 42c3da4c62..7dd20c4c5a 100644--- a/backend/plugin/db/util/ssh.go+++ b/backend/plugin/db/util/ssh.go@@ -25,17 +25,16 @@ func GetSSHClient(cfg db.SSHConfig) (*ssh.Client, error) {}sshConfig.Auth = append(sshConfig.Auth, ssh.PublicKeys(signer))} else {- // Establish a connection to the local ssh-agent- conn, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))- if err != nil {- return nil, err- }- defer conn.Close()- // Create a new instance of the ssh agent- agentClient := agent.NewClient(conn)- // When the agentClient connection succeeded, add them as AuthMethod- if agentClient != nil {- sshConfig.Auth = append(sshConfig.Auth, ssh.PublicKeysCallback(agentClient.Signers))+ // Users may use ssh-agent to store the private key with passphrase,+ // we will try to connect to the ssh-agent to get the private key.+ if conn, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {+ defer conn.Close()+ // Create a new instance of the ssh agent+ agentClient := agent.NewClient(conn)+ // When the agentClient connection succeeded, add them as AuthMethod+ if agentClient != nil {+ sshConfig.Auth = append(sshConfig.Auth, ssh.PublicKeysCallback(agentClient.Signers))+ }}}// When there's a non empty password add the password AuthMethod.