1
1
mirror of https://gitea.com/gitea/tea synced 2024-11-23 00:12:05 +01:00

Return useful error on wrong sshkey path (#374)

close #366

Reviewed-on: https://gitea.com/gitea/tea/pulls/374
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
6543 2021-06-29 15:54:43 +08:00
parent 616127cedc
commit ebb2c38a0a

@ -55,7 +55,7 @@ func readSSHPrivKey(keyFile string, passwordCallback pwCallback) (sig ssh.Signer
} }
sshKey, err := ioutil.ReadFile(keyFile) sshKey, err := ioutil.ReadFile(keyFile)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("can not read ssh key '%s'", keyFile)
} }
sig, err = ssh.ParsePrivateKey(sshKey) sig, err = ssh.ParsePrivateKey(sshKey)
if _, ok := err.(*ssh.PassphraseMissingError); ok && passwordCallback != nil { if _, ok := err.(*ssh.PassphraseMissingError); ok && passwordCallback != nil {