diff options
| author | Shulhan <ms@kilabit.info> | 2021-04-05 00:54:35 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-04-05 01:32:55 +0700 |
| commit | 774f7f341eee1de4dd7cf719e88bfee9bcea9570 (patch) | |
| tree | 2817ac69cf1fc90341f9ca3d73ab5fe68b7a65f6 /lib/ssh/client.go | |
| parent | a211773aba0da9fbd642c2a4a172cc90efaf02d5 (diff) | |
| download | pakakeh.go-774f7f341eee1de4dd7cf719e88bfee9bcea9570.tar.xz | |
ssh: ask for passphrase if private key is encrypted on generateSigners
In case the private key defined in IdentityFile is encrypted, prompt
for the passphrase on the screen and read it from stdin using
term.ReadPassword().
This changes also remove call to generateSigners on postConfig(),
instead invoke it from NewClient() to minimize multiple calls to
generateSigners().
Diffstat (limited to 'lib/ssh/client.go')
| -rw-r--r-- | lib/ssh/client.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ssh/client.go b/lib/ssh/client.go index d3ae9af6..5e6871c0 100644 --- a/lib/ssh/client.go +++ b/lib/ssh/client.go @@ -31,6 +31,11 @@ func NewClient(cfg *ConfigSection) (cl *Client, err error) { cfg.postConfig("") + err = cfg.generateSigners() + if err != nil { + return nil, err + } + sshConfig := &ssh.ClientConfig{ User: cfg.User, Auth: []ssh.AuthMethod{ |
