Golang gliderlabs/ssh public key authentication with authorized_keys

391 views Asked by At

I have a problem with authentication using multiple public keys. I used example from gliderlabs/ssh github but it is only using first public key in the file and discard every other.

func ExamplePublicKeyAuth() {
    ssh.ListenAndServe(":2222", nil,
        ssh.PublicKeyAuth(func(ctx ssh.Context, key ssh.PublicKey) bool {
            data, _ := ioutil.ReadFile(path.Join(os.Getenv("HOME"), ".ssh/authorized_keys"))
            allowed, _, _, _, _ := ssh.ParseAuthorizedKey(data)
            return ssh.KeysEqual(key, allowed)
        }),
    )
}

Does anyone know how to make it work with multiple public keys?

0

There are 0 answers