假设你当前的私钥文件为 `~/.ssh/id_rsa`:
-
打开终端,执行以下命令设置权限及运行取消密码命令:
chmod 600 ~/.ssh/id_rsa chmod 700 ~/.ssh ssh-keygen -p -f ~/.ssh/id_rsa -
然后按提示操作:
Enter old passphrase: # 输入旧密码 Key has comment '...' Enter new passphrase (empty for no passphrase): # 直接回车,表示不设置新密码 Enter same passphrase again: # 再次回车确认 -
按提示操作:
- 输入旧密码
- 新密码留空,直接回车,即可取消密码保护
输出结果如下,说明你已经成功取消了私钥密码(即设置为空密码):
Enter new passphrase (empty for no passphrase): ← 你留空了
Enter same passphrase again: ← 再次留空确认
Your identification has been saved with the new passphrase.