24 lines
414 B
Go
24 lines
414 B
Go
package ussher
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"golang.org/x/crypto/ssh"
|
|
)
|
|
|
|
type Config struct {
|
|
HostKeyPath string
|
|
Keystore Keystore
|
|
}
|
|
|
|
func (c *Config) GetPrivateKey() (ssh.Signer, error) {
|
|
bytes, err := ioutil.ReadFile(c.HostKeyPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ssh.ParsePrivateKey(bytes)
|
|
}
|
|
|
|
type Keystore interface {
|
|
CheckPublicKey(user string, key ssh.PublicKey) (*ssh.Permissions, error)
|
|
}
|