sveale / remote-edit

remote-edit
MIT License
146 stars 55 forks source link

Uncaught Error: Malformed private key (expected sequence). Bad passphrase? #162

Open Hufschmidt opened 8 years ago

Hufschmidt commented 8 years ago

I'm getting a similar error to #121 but want to post additional information. (Sadly I can't reopen it)

Uncaught Error: Malformed private key (expected sequence). Bad passphrase?

/home/hufschmt/.atom/packages/remote-edit/node_modules/ssh2/node_modules/ssh2-streams/lib/utils.js:307
Hide Stack Trace
Error: Malformed private key (expected sequence). Bad passphrase?
    at genPublicKey (/home/hufschmt/.atom/packages/remote-edit/node_modules/ssh2/node_modules/ssh2-streams/lib/utils.js:307:13)
    at Client.connect (/home/hufschmt/.atom/packages/remote-edit/node_modules/ssh2/lib/client.js:155:29)
    at /home/hufschmt/.atom/packages/remote-edit/lib/model/sftp-host.coffee:124:23
    at fn (/usr/share/atom-beta/resources/app.asar/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js:638:34)
    at Immediate._onImmediate (/usr/share/atom-beta/resources/app.asar/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js:554:34)
    at processImmediate [as _immediateCallback] (timers.js:374:17)

Config: Generated via "Add new host (sftp)", changed username, switched to private_key, changed key-path, left password blank!

{  
  "hostList":[  
    {  
      "alias":"",
      "hostname":"vhrz388",
      "directory":"/",
      "username":"root",
      "port":"22",
      "localFiles":[ ],
      "useAgent":false,
      "usePrivateKey":true,
      "usePassword":false,
      "passphrase":"",
      "privateKeyPath":"/home/hufschmt/.ssh/hrz",
      "deserializer":"SftpHost"
    }
  ],
  "deserializer":"InterProcessData"
}

With this config I get the above error when selecting the host from the "Browse Hosts" list. I do not get asked for any password!

Additonal Information: OS: (K)Ubuntu 15.04 (64 Bit) Atom: 1.4.0 Beta 3 Remote-Edit: 1.8.23 Key-Type: OpenSSH, RSA (non-binary, aka "armored")

Workaround 1: (not working) Changing "userPassword" to true enables the password question after selecting the host, but even entering the correct password there produces the above error...

Workaround 2: (working but suboptimal) Edit the host and add a password. Here comes the fun part, this actually works! (But is sub-optimal since my ssh-key is very sensitive...)

Workaround 3: (working and I could live with it) Switch back to User-Agent mode and add my ssh-key to the systems ssh user-agent (aka ssh-add ~/ssh/.hrz). This works and does not potentially compromise my ssh-keys password.

Conclusion:

Workaround 2 and 3 show that a) My private-key works and can be read/used by the node ssh2 module b) The node ssh2 module can talk to the ssh-agent

Workaround 1 and 2 indicate that the error seems to be caused by remote-edit and not the underlying ssh2 module, since a) It detected the empty password field wrongly (Workaround 1) b) Using the password dialog (Workaround 2) seems to be broken, while reading it from the config (Workaround 3) works

eby commented 8 years ago

Same problem. No prompt for key on el capitan. Agent workaround works.

mfferreira commented 8 years ago

Bump