To delete SSH keys from a cloud server, follow these steps based on the operating system and access method:
SSH keys are typically stored in the ~/.ssh/authorized_keys file for user accounts. To remove a key:
Step 1: Connect to the server via SSH:
ssh username@server_ip
Step 2: Open the authorized_keys file:
nano ~/.ssh/authorized_keys
(Or use vim, vi, or any text editor.)
Step 3: Locate the key you want to delete (it starts with ssh-rsa or similar) and remove the entire line.
Step 4: Save the file and exit the editor.
Example:
If the key is:
ssh-rsa AAAAB3NzaC1yc2E... user@example.com
Delete that entire line.
If the server uses OpenSSH (Windows 10/11 or Windows Server 2019+):
Get-Content C:\Users\username\.ssh\authorized_keys
notepad C:\Users\username\.ssh\authorized_keys
Delete the key line and save.If the SSH key was added via Tencent Cloud’s Key Pair feature:
~/.ssh/authorized_keys on the server if needed.Note: Deleting a key pair from the console does not automatically remove it from servers where it was manually added.
If you want to temporarily block a key, you can modify the sshd_config file (Linux):
sudo nano /etc/ssh/sshd_config
Add or modify:
DenyUsers username
Then restart SSH:
sudo systemctl restart sshd
This prevents the user from logging in, even if the key exists.
For Tencent Cloud, you can also reset the instance password or disable login temporarily from the console if needed.