恢复误删的SSH密钥可以按照以下步骤进行:
~/.ssh/目录下,例如id_rsa和id_rsa.pub。id_rsa)和公钥(如id_rsa.pub)复制到~/.ssh/目录下。chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
sudo systemctl restart sshd
或者对于使用init.d的系统:sudo /etc/init.d/ssh restart
如果无法从备份中恢复,你将需要重新生成SSH密钥对。
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
~/.ssh/id_rsa)并设置密码(可选)。id_rsa.pub)内容添加到需要访问的服务器的~/.ssh/authorized_keys文件中。authorized_keys文件:ssh-copy-id user@remote_host
或者手动复制公钥内容并粘贴到远程服务器的~/.ssh/authorized_keys文件中。ssh -i ~/.ssh/id_rsa user@remote_host
通过以上步骤,你应该能够成功恢复误删的SSH密钥或重新生成新的密钥对。