更换库

This commit is contained in:
2023-03-25 09:06:37 +08:00
parent 4878a9e21f
commit 1f251c8b1c
16 changed files with 677 additions and 411 deletions

21
src/private_key_file.go Normal file
View File

@@ -0,0 +1,21 @@
package main
import (
"io/ioutil"
"golang.org/x/crypto/ssh"
)
func PrivateKeyFile(file string) ssh.AuthMethod {
buffer, err := ioutil.ReadFile(file)
if err != nil {
return nil
}
key, err := ssh.ParsePrivateKey(buffer)
if err != nil {
return nil
}
return ssh.PublicKeys(key)
}