When the Linux home directory is encrypted, you will not be able to use ssh key login by simply copying ssh-copy-id mechanism. to overcome this issue you will have to move the authorized key out of home directory as default location is inside the home directory which is encrypted in this scenario.
Let's take client as the machine your currently logged in and server as the machine you want to access using ssh keys.
1. log in to the client and do a ssh-copy-id
ssh-copy-id -i .ssh/id_rsa.pub <user-name>@<server-ip>
2. now log in to server and copy the authorized file to a different location
cp ~/.ssh/authorized_keys /etc/ssh/nuwan/authorized_keys
3. check the owner of the file moved. it should be accessible by our user. if not change owner as following
sudo chown <user-name> authorized_keys
4. set the file permission
chmode 640 authorized_keys
5. now we should configure sshd file for the new ssh suthorzed file location. go to
/etc/ssh/sshd_config and uncomment AuthorizedKeysFile line and set the path for the authorizised file
AuthorizedKeysFile /etc/ssh/nuwan/authorized_keys
6. as the final step sshd service restart is required.
sudo service sshd restart
now we are done. test the connectivity by log in to client and issue the following command.
ssh <user-name>@<server-name>
you should be log without entering the password.
Let's take client as the machine your currently logged in and server as the machine you want to access using ssh keys.
1. log in to the client and do a ssh-copy-id
ssh-copy-id -i .ssh/id_rsa.pub <user-name>@<server-ip>
2. now log in to server and copy the authorized file to a different location
cp ~/.ssh/authorized_keys /etc/ssh/nuwan/authorized_keys
3. check the owner of the file moved. it should be accessible by our user. if not change owner as following
sudo chown <user-name> authorized_keys
4. set the file permission
chmode 640 authorized_keys
5. now we should configure sshd file for the new ssh suthorzed file location. go to
/etc/ssh/sshd_config and uncomment AuthorizedKeysFile line and set the path for the authorizised file
AuthorizedKeysFile /etc/ssh/nuwan/authorized_keys
6. as the final step sshd service restart is required.
sudo service sshd restart
now we are done. test the connectivity by log in to client and issue the following command.
ssh <user-name>@<server-name>
you should be log without entering the password.
Comments
Post a Comment