Contents

A case of vscode key-based login failing

Background

After some system update, vscode’s ssh server started asking for a password. The machine sleeps a lot, and re-entering the password for every open project was not acceptable.

Diagnosis

The vscode output panel showed only the password prompt and nothing that explained why:

[16:36:47.687] Remote-SSH version: remote-ssh@0.102.0
[16:36:47.688] SSH Resolver called for “ssh-remote+x.x.x.x”, attempt 1
[16:36:49.196] Found password prompt in other window
[16:36:49.197] Showing password prompt

So I ran ssh root@x.x.x.x -v in a terminal and read the debug output:

debug1: Offering public key: /Users/xxx/.ssh/id_rsa RSA SHA256:p+xx+xx+BaSI explicit
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Next authentication method: keyboard-interactive
(root@x.x.x.x) Password:

The key was found and offered, and it wasn’t the usual permission problem either (a wrongly permissioned id_rsa, 777 for example, is another classic way for this to fail silently).

The giveaway is no mutual signature algorithm: openssl treats ssh-rsa as insecure, the update bumped the openssl version, and the server no longer accepts an ssh-rsa signature even though the client still offers one.

Fix

Any one of these works:

  1. Allow it globally on the client. Add a line to /etc/ssh/ssh_config:

    PubkeyAcceptedKeyTypes +ssh-rsa
  2. Allow it for this host only. Edit ~/.ssh/config (or the equivalent in vscode):

    Host x.x.x.x
        HostName x.x.x.x
        User root
        Port 22
        PubkeyAcceptedKeyTypes +ssh-rsa
  3. Generate a new key with a supported algorithm:

    ssh-keygen -t ed25519 -C "xx@xx.com"

    Run man ssh-keygen for the full list of algorithms.

Note: since OpenSSH 8.5 the option is called PubkeyAcceptedAlgorithms; the old name is kept as an alias.