修復 Ubuntu 22.04 無法使用 ssh(rsa) key 登入
ssh ubuntu ssh -編輯 sshd_config 檔案
/etc/ssh/sshd_config
PubkeyAcceptedKeyTypes +ssh-rsa
當使用 ssh 登入 Ubuntu 22.04 以上版本的系統,出現以下錯誤訊息:
Permission denied (publickey).。但檢查所有的設定卻都沒有問題時。
Why
因為 Ubuntu 22.04 之後認為 ssh-rsa 已經不安全了,所以預設不支援。
How
要恢復支援 ssh-rsa 的功能,可以有兩種方法:
- 
將支援設定加入設定檔 
編輯 sshd_config 檔案
/etc/ssh/sshd_config
PubkeyAcceptedKeyTypes +ssh-rsa
重新啟動 sshd
> sudo systemctl restart sshd- 
或重新用更安全的編碼產生 ssh key
例如用 ed25519 產生 ssh key。
> ssh-keygen -t ed25519 -C "newkey"再將 public key 加入到 ~/.ssh/authorized_keys 檔案中。