当我将我的Amazon EC2实例的主目录从/ home / ubuntu更改为/ etc / passwd文件中的/ home / ubuntu /文件夹时,我不再能够使用我现有的密钥对来访问实例。 一旦我切换回原来的目录,我没有问题,可以正常login到我的实例。 我已经检查了新文件夹的权限,它们是drwxr-xr-x,它与/ home / ubuntu文件夹相同。 我有一些实例正在运行,由于这个变化,我没有办法重新login来纠正这种情况。 有没有人有一个想法是怎么回事?
您需要将.ssh文件夹复制到新的主目录(这似乎是您的,但仍然提醒您)。 如果您正在使用StrictMode,则还必须确保.ssh文件夹具有正确的权限(请参阅下文)
StrictModes Specifies whether sshd should check file modes and ownership of the user's files and home directory before accepting login. This is normally desirable because novices sometimes accidentally leave their directory or files world-writable. The default is yes.
严格模式所需的权限
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys