elliotchance / sshtunnel

🚇 Ultra simple SSH tunnelling for Go programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add PrivateKeyFileWithPassphrase

fagnercarvalho opened this issue · comments

Could we please add a PrivateKeyFileWithPassphrase for parsing private key files with a passphrase?

I can create a PR for it if you want to.

func PrivateKeyFileWithPassphrase(file string, passphrase string) ssh.AuthMethod {
	buffer, err := ioutil.ReadFile(file)
	if err != nil {
		return nil
	}

	key, err := ssh.ParsePrivateKeyWithPassphrase(buffer, []byte(passphrase))
	if err != nil {
		return nil
	}

	return ssh.PublicKeys(key)
}

Yes. Please add a PR for this :)