Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Although, I need to perform the same install again on another couple of client/server boxes (same hardware, same distros). I have written down everything I did, so there's good probability I'll come across the same issue if I repeat the steps. I'll update this post in case I find out what was causing this problem.
In the meantime, I have marked this thread as solved.
I have found something interesting. The fact that it worked had nothing to do with the reboots. Actually what happens is:
If the same user is already logged into the server (whether that be locally or via another ssh session), key authentication works,
If they are not, key authentication fails
When it fails, it (as previously) is because the server can't open the authorized_keys file:
Code:
debug1: Could not open authorized keys '/home/me/.ssh/authorized_keys': No such file or directory
I can now reproduce this consistently.
I try to log into the server via SSH --> key authentication fails
I log into the server physically
I try to log into the server via SSH again --> key authentication WORKS
I exit the local session
I try to log into the server via SSH again --> key authentication fails
I did not change any rights or ownership. I don't understand this behaviour. I tried and google for something similar but could not find anything relevant. Am I missing something?
Is your home directory encrypted? One symptom is being unable to use keys unless already logged in. If so, you'll have to configure sshd to store keys in a second place, outside the encrypted directory using "AuthorizedKeysFile" in sshd_config. You could make a directory /etc/ssh/remslug and put the keys there. Then sshd_config could contain something like this:
What is type of /home FS ?
Did you checked, what the state of selinux as i said above ?
My /home filesystem is ext4.
SELinux is disabled (which is the default on Mint).
Code:
#$ getenforce
Disabled
Quote:
Is your home directory encrypted? One symptom is being unable to use keys unless already logged in. If so, you'll have to configure sshd to store keys in a second place, outside the encrypted directory using "AuthorizedKeysFile" in sshd_config.
Good point. Yes, my filesystem is encrypted. That might be the problem.
I have copied authorized_keys in /etc/ssh/me/ and added the following line in /etc/ssh/sshd_config:
Are you sure that /home/me/.ssh/authorized_keys exist on server side ?
As I see, user "me" has UID/GID 1000/1000:
If you login as "me" on server, could you do "cat /home/me/.ssh/authorized_keys" ?
If you still has no solution, probably it is selinux problem.
Please set it to PERMISSIVE and check what happen in /var/log/messages.
I don't agree with this advice. Editing the file may very likely cause selinux issues so it is better to run
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.