feat: read pubkey from file
This commit is contained in:
10
main.go
10
main.go
@@ -18,7 +18,6 @@ import (
|
|||||||
gossh "golang.org/x/crypto/ssh"
|
gossh "golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
const SK_ECDSA_PUBKEY = "sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBIEy/KQzi+q7uqufEtqHXusQbpT9GVM2j1jNhU83VI8T8VOy4nWX9STNU+qpcwp6l1wqhYZSmMRkXF+3CwCAssAAAAAEc3NoOg== fido-u2f"
|
|
||||||
const WELCOME = ", . . . \n" +
|
const WELCOME = ", . . . \n" +
|
||||||
"| . | | | \n" +
|
"| . | | | \n" +
|
||||||
"| ) ) ,-. | ,-. ,-. ;-.-. ,-. |- ,-. \n" +
|
"| ) ) ,-. | ,-. ,-. ;-.-. ,-. |- ,-. \n" +
|
||||||
@@ -33,7 +32,7 @@ const WELCOME = ", . . .
|
|||||||
" \n"
|
" \n"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sshPublicKey, sshPublicKeyErr := parseSshPubkey(SK_ECDSA_PUBKEY)
|
sshPublicKey, sshPublicKeyErr := parseSshPubkey()
|
||||||
if sshPublicKeyErr != nil {
|
if sshPublicKeyErr != nil {
|
||||||
log.Fatal("Parse sk ecdsa public key failed: ", sshPublicKeyErr)
|
log.Fatal("Parse sk ecdsa public key failed: ", sshPublicKeyErr)
|
||||||
return
|
return
|
||||||
@@ -92,7 +91,12 @@ func setWinsize(f *os.File, w, h int) {
|
|||||||
uintptr(unsafe.Pointer(&struct{ h, w, x, y uint16 }{uint16(h), uint16(w), 0, 0})))
|
uintptr(unsafe.Pointer(&struct{ h, w, x, y uint16 }{uint16(h), uint16(w), 0, 0})))
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSshPubkey(pubkey string) (gossh.PublicKey, error) {
|
func parseSshPubkey() (gossh.PublicKey, error) {
|
||||||
|
pubkeyBytes, pubkeyErr := ioutil.ReadFile("allowed_key")
|
||||||
|
if pubkeyErr != nil {
|
||||||
|
return nil, pubkeyErr
|
||||||
|
}
|
||||||
|
pubkey := strings.TrimSpace(string(pubkeyBytes))
|
||||||
if strings.Contains(pubkey, " ") {
|
if strings.Contains(pubkey, " ") {
|
||||||
pubkey = strings.Split(pubkey, " ")[1]
|
pubkey = strings.Split(pubkey, " ")[1]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user