Jos*_*osh 39 linux ssh disk-encryption remote-login
我最近使用 Ubuntu karmic 9.10 设置了一个新服务器,当我创建我的主目录时,我选择对其进行加密。现在,将我的authorized_keys 文件加载到~/.ssh 后,它无法被识别,因为我的主目录直到我登录后才被解密。有没有办法让SSH 密钥与Ubuntu 下的加密主目录一起使用?
djh*_*ell 38
在 sshd_config 文件中更改这一行:
AuthorizedKeysFile /etc/ssh/%u/authorized_keys
Run Code Online (Sandbox Code Playgroud)
然后将您的 authorized_keys 文件移动到 /etc/ssh/your-username/authorized_keys
这篇文章记录了解决这个问题的另一种方法。
小智 7
这个解决方案的灵感来自这篇文章。恕我直言,它比修改您的 /etc/ssh/sshd_config 好得多,因为它根本不需要 root 访问权限。
# Make your public key accessible
mkdir -m 700 /home/.ecryptfs/$USER/.ssh
echo $YOUR_PUBLIC_KEY > /home/.ecryptfs/$USER/.ssh/authorized_keys
ln -s /home/.ecryptfs/$USER/.ssh/authorized_keys ~/.ssh/authorized_keys
ecryptfs-umount-private
chmod 700 $HOME
mkdir -m 700 ~/.ssh
ln -s /home/.ecryptfs/$USER/.ssh/authorized_keys ~/.ssh/authorized_keys
# Make it auto-mount with first login.
# Note: it can cause problems with automated login.
echo /usr/bin/ecryptfs-mount-private > ~/.profile
echo cd >> ~/.profile
echo source .profile >> ~/.profile
ecryptfs-mount-private
Run Code Online (Sandbox Code Playgroud)