From d5502f7d21b0c300ecd86b115d97ea9210a3315a Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Sun, 20 Feb 2022 17:32:24 +0000 Subject: [PATCH] Set the outputted pubkey to be the authorized key representation --- utils/utils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 5631f0c..7ebffab 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -450,7 +450,10 @@ func GetSSHConfig() *ssh.ServerConfig { return nil, fmt.Errorf("password doesn't match") }, PublicKeyCallback: func(c ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { - log.Printf("Login attempt: %s, user %s key: %s", c.RemoteAddr(), c.User(), string(ssh.MarshalAuthorizedKey(key))) + authKey := ssh.MarshalAuthorizedKey(key) + authKey = authKey[:len(authKey)-1] + + log.Printf("Login attempt: %s, user %s key: %s", c.RemoteAddr(), c.User(), string(authKey)) holderLock.Lock() defer holderLock.Unlock() @@ -458,7 +461,7 @@ func GetSSHConfig() *ssh.ServerConfig { if bytes.Equal(key.Marshal(), i.Marshal()) { permssionsData := &ssh.Permissions{ Extensions: map[string]string{ - "pubKey": string(key.Marshal()), + "pubKey": string(authKey), "pubKeyFingerprint": ssh.FingerprintSHA256(key), }, }