Skip to content

Commit

Permalink
Merge pull request #215 from antoniomika/am/fix-pubkey-marshal
Browse files Browse the repository at this point in the history
Set the outputted pubkey to be the authorized key representation
  • Loading branch information
antoniomika authored Feb 20, 2022
2 parents 620351a + d5502f7 commit 84b6d6a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,18 @@ 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()
for _, i := range certHolder {
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),
},
}
Expand Down

0 comments on commit 84b6d6a

Please # to comment.