This commit is contained in:
Rafael Peroco 2026-05-22 07:12:12 +08:00 committed by GitHub
commit 4273d6b33f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -27,6 +27,7 @@ import (
"net"
"os"
"path"
"strings"
"time"
cryptssh "golang.org/x/crypto/ssh"
@ -321,6 +322,10 @@ func LoadKeyPairFromPath(path, password string) (*ssh.KeyPair, error) {
return nil, nil
}
if strings.HasPrefix(path, "~") {
return nil, fmt.Errorf("failed to open private key file: path %q starts with '~' which is not expanded; use an absolute path or $HOME", path)
}
b, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to open private key file: %w", err)