Glen Pitt-Pladdy :: BlogUbuntu, encrypted home directories and ssh key authentication | |||
There's plenty on the web about this subject but none of it seems to be the complete story. Ubuntu allows you to encrypt your home directories which is great where improved security is needed (eg. laptops), however it means that ssh can't pick up the ~/ssh/authorized_keys and then a whole lot of other messy stuff happens once you fix that. Getting the keysThe first problem is that when the ssh connection occurs the encrypted home directory doesn't yet exist. Solution: create an alternative authorized_keys file. Create a directory (with appropriate ownership and permissions called say /etc/ssh/yourusername). Put your authorized_keys file in that. Then without your encrypted home directory mounted create a ~/.ssh directory and symlink your real authorized_keys file from /etc/ssh/yourusername/authorized_keys into that directory. When you connect that file can be read. Once your home directory is mounted you can do the same with the encrypted ~/.ssh which will take care of when your home directory is already mounted when you connect. Mounting the encrypted home directoryWhen you connect with ssh keys now you will find your home directory isn't mounted. The README.txt file will help you, but it would be much neater if this happened automatically. The simple way is to create a ~/.profile file that mounts your home directory, but the observant will notice that this will mean that the ~/.profile in your encrypted home directory will never be run and that may mean the shell will behave differently depending how you login. In my case I end up with not all the auto-completion and other neat things missing. The trick is the last line here:
/usr/bin/ecryptfs-mount-private That mounts the home directory (if needed), changes directory to the newly mounted home directory, and finally runs the ~/.profile from the encrypted home directory. All sorted! |
|||
Disclaimer: This is a load of random thoughts, ideas and other nonsense and is not intended to be taken seriously. I have no idea what I am doing with most of this so if you are stupid and naive enough to believe any of it, it is your own fault and you can live with the consequences. More importantly this blog may contain substances such as humor which have not yet been approved for human (or machine) consumption and could seriously damage your health if taken seriously. If you still feel the need to litigate (or whatever other legal nonsense people have dreamed up now), then please address all complaints and other stupidity to yourself as you clearly "don't get it".
Copyright Glen Pitt-Pladdy 2008-2023
|
Comments: