func newStubKeyring(pemBytes []byte) (*stubKeyring, error) { signer, err := gossh.ParsePrivateKey(pemBytes) if err != nil { return nil, err } return &stubKeyring{signer}, err }
func getTestPublicKey(t *testing.T) ssh.PublicKey { priv, err := ssh.ParsePrivateKey([]byte(testClientPrivateKey)) if err != nil { t.Fatalf("ParsePrivateKey: %v", err) } return priv.PublicKey() }
func init() { template.Must(configTmpl.Parse(sshd_config)) for n, k := range map[string]*ssh.Signer{ "ssh_host_ecdsa_key": &hostKeyECDSA, "ssh_host_rsa_key": &hostKeyRSA, "ssh_host_dsa_key": &hostKeyDSA, } { var err error *k, err = ssh.ParsePrivateKey([]byte(keys[n])) if err != nil { panic(fmt.Sprintf("ParsePrivateKey(%q): %v", n, err)) } } var err error privateKey, err = ssh.ParsePrivateKey([]byte(testClientPrivateKey)) if err != nil { panic(fmt.Sprintf("ParsePrivateKey: %v", err)) } }
func (k *keychain) loadPEM(file string) error { buf, err := ioutil.ReadFile(file) if err != nil { return err } key, err := ssh.ParsePrivateKey(buf) if err != nil { return err } k.keys = append(k.keys, key) return nil }