vscode-sftp: Unsupported key format for openssh format (Mac Mojave)

When a ssh key is generated with or without a passphrase, it results in an unsupported key format error.

The key works fine for SSH and other applications.

Key Header: -----BEGIN OPENSSH PRIVATE KEY-----

Steps to reproduce the behavior:

  1. Generate a new key file with the following command. Set a passphrase.

ssh-keygen -t rsa -b 4096

  1. Try to use this key in the extension within VSCode. You will receive the error “Unsupported key format”.

NOTE and WORKAROUND: The key also will not be read by puttygen to convert the key to a .ppk if the key has a passphrase. Another error, “Unsupported Cipher” is returned when importing the key. However, if the passphrase is removed from that key via

ssh-keygen -p id_rsa

then the key is loaded fine by puttygen and can be exported to a .ppk that works fine in vscode-sftp.

Expected behavior I expected the plugin to accept the format of the key as it does when I use the same command in either WSL(Windows Sub-systems for Linux) or in Ubuntu/Fedora. (Used VSCode on all of these platforms).

Macbook Pro: OS: MacOS Mojave 10.14.1 VSCode: 1.28.2 Extension Version: 1.7.3 SSH Version: OpenSSH_7.8p1, LibreSSL 2.7.3

Extension Log(Some private data has been omitted):

{"remotePath":"/","uploadOnSave":true,"downloadOnOpen":false,"ignore":[".vscode",".git",".DS_Store","vendor/*","node_modules"],"concurrency":4,"protocol":"sftp","connectTimeout":10000,"interactiveAuth":false,"secure":false,"passive":false,"remoteTimeOffsetInHours":0,"port":22,"host":"","username":"******","privateKeyPath":"/Users/cjcox17/.ssh/sftp_test_key","passphrase":"******"} [error] Error: Cannot parse privateKey: Unsupported key format at Client.connect (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/node_modules/ssh2/lib/client.js:231:13) at Promise (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:231:22) at new Promise (<anonymous>) at SSHClient.<anonymous> (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:209:20) at Generator.next (<anonymous>) at /Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:7:71 at new Promise (<anonymous>) at __awaiter (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:3:12) at SSHClient._connectSSHClient (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:202:16) at SSHClient.<anonymous> (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:74:24) at Generator.next (<anonymous>) at fulfilled (/Users/cjcox17/.vscode/extensions/liximomo.sftp-1.7.3/out/src/core/remote-client/sshClient.js:4:58) at <anonymous>

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

@cjcox17 @fanshengshuai @biu0w0 @sydneyjean We need to wait for the upstream library to support this.

Here is some workarounds:

  • Downgrade your ssh-keygen binary (you can easily get old version from any linux/docker image)
  • Add option -m PEM into your ssh-keygen command. For example, you can run ssh-keygen -m PEM -t rsa -b 4096 -C “your_email@example.com” to force ssh-keygen to export as PEM format.

I am experiencing the same issue on Mac Mojave 10.14.1. I have a key generated without passcode. We need a solution that must work with existing key. I think this extension needs changes to support the format to work with Mac Mojave

  1. “BEGIN OPENSSH PRIVATE KEY”….
    • Env: Mac Mojave 10.14.1
  • Generate new ssh key with old format “BEGIN RSA PRIVATE KEY” * ssh-keygen -m PEM

  • Covert Old id_rsa Private Key = puttygen * puttygen <fileInput> -O <format> -o <output> * puttygen id_rsa -O private-openssh -o id_rsa_new

https://kmagen2.wordpress.com/2019/01/04/begin-openssh-private-key-begin-rsa-private-key/

@kietluuu What version of puttygen are you using, please? On puttygen v0.67 I have here, your very promising suggestion: puttygen id_rsa -O private-openssh -o id_rsa_new complains with: puttygen: this command would perform no useful action.

Following down the rabbit hole of your supplied link gets me here, but with the same result. I can’t create an updated (RFC4716 compliant) version of my old private key.