Changing SSH keys on server doesn't work

mehki 0 Reputation points

I removed the current SSH key and added new one, in connect section of VPS I refreshed the key and it said that it updated successfully but I can still access with old one while I cannot access with new one.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,374 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sedat SALMAN 13,265 Reputation points

    yes you can also replace/manage your SSH key from the UI/Azure Dashboard also

    • Choose your VM
    • "Settings" and select "Reset password".
    • You'll see three options - Reset password, Reset SSH public key, and Reset SSH public key and password. Select "Reset SSH public key".
    • Enter your username and paste your new public SSH key in the appropriate fields.

    Please note that this process will not remove the old SSH key. The old key will still be able to access the VM unless you manually remove it from the ~/.ssh/authorized_keys file in the VM.

    However, if you don't want to use the CLI, you can't manually remove the old SSH key from the ~/.ssh/authorized_keys file, which might be why you're still able to access the VM with the old key.

    To completely replace the SSH key without CLI, you may need to redeploy the VM. Redeployment resets the SSH configuration, including the SSH key

    0 comments No comments

  2. sam john 0 Reputation points

    If you made any changes restart the ssh server on your system to make the changes effect by running the command in the terminal :**
    sudo systemctl restart sshd**

    0 comments No comments