Ubuntu 20.04 Chrome 密钥提示 SSH 访问 解决方法
你在 Ubuntu 20.04 通过 SSH 远程登录后运行 Chrome,仍然弹出“解锁登录密钥环”提示,是因为:
SSH 默认不会解锁 GNOME Keyring(密钥环),而 Chrome 启动时又依赖它保存密码、Cookie 等数据,因此会反复提示输入密码。
✅ 解决方法(适用于 SSH 远程会话)
✅ 方法 1:修改 Chrome 启动参数,跳过密钥环
强制 Chrome 使用“基础密码存储”,不再依赖 GNOME Keyring:
1 | google-chrome-stable --password-store=basic |
永久生效(对所有用户):
1 | sudo sed -i 's|^Exec=/usr/bin/google-chrome-stable|Exec=/usr/bin/google-chrome-stable --password-store=basic|' /usr/share/applications/google-chrome.desktop |
✅ 方法 2:手动解锁密钥环(一次性)
如果你必须使用密钥环(如保存密码),在 SSH 会话中手动解锁:
1 | export DISPLAY=:0 |
注意:此方法需要你在本地已登录图形界面,且 SSH 用户与桌面用户一致。
✅ 方法 3:使用 dbus-launch
启动 Chrome(兼容性好)
在 SSH 中启动 Chrome 时加上 dbus-launch
,可自动连接会话:
1 | dbus-launch google-chrome-stable |
⚠️ 不推荐的做法
- 禁用密钥环或删除
~/.local/share/keyrings
会导致密码丢失; - 取消自动登录对 SSH 无帮助。
✅ 一句话总结
SSH 远程登录后运行 Chrome 提示密钥 → 使用
--password-store=basic
参数跳过密钥环即可。