I have an interesting issue with my Ubuntu box that I feel like is probably just a configuration issue on my part but hopefully one of you wizards can help me figure it out.

I have an Ubuntu 18.04.4 install that I use for video game servers for my friends and I. At the moment, I have Minecraft and Terraria running on it. These servers run within their own user (I have a Minecraft user and a Terraria user) to keep things separated. Additionally, I have a privileged user that has access to juuuust about everything with sudo.

I setup key-based authentication on my server as the title implies. I followed a YouTube video on how to set it up, which guided me to create a ".ssh" directory inside my main user's home directory, and use that to store the authorized keys. The .ssh folder has 700 privileges, and the rest of the files inside are 600. Did all that, bippy boppity boom! It works!

So If I open putty and ssh into my server it works fine as long as I choose the privileged user as the user in which I wish to login as. If I try to login as the Minecraft or Terraria user, no dice, the server rejects the key. I tried creating the same .ssh/authorized_keys folder for the Minecraft user to test my theory that I needed to have the public key also in the Minecraft user's home directory for it to work. Still no dice. (this was my issue that the below answer solved. The key in this file was not a single line) Infact, there isn't really a typical home directory for either of the other users.

The privileged user has a home folder in /home/USER/ but the others do not, and I feel like this may be the root of my issue but I am unsure how to go about creating this directory for my users without breaking the installations of the servers that operate on them.

That's about what I have going on here, and if any of you folks have insight as to why my ssh isn't working for those users I would love to hear it. Thanks in advance!

1 Answer 1


Have a look at your current users by typing cat /etc/passwd. The parameters on each line are separated by a colon : the second-to-last parameter is the users home dir. The last parameter is the users shell (or it might be something like nologin or false if the user has been configured to disallow a login).

You can add users via the useradd and usermod to modify users. Take a look at the man pages for those commands.

Sometimes when an installer is run it may add a user but that user is not intended to be used to login (say for for security reasons) so you may need to modify the home dir or shell or just add other different users for allowing remote login. It depends what you want to do or what users or access you want to give.

What you are trying to do should work so maybe something wrong with the keys file or something wrong with file ownership permissions.

Check that the SINGLE line from your source machine id_rsa.pub is on the target machine ~/.ssh/authorized_keys file. Double check that if you cut/pasted this line it hasn't pasted as multiple lines. It is a single line.

Check that the target user (your Minecraft or Terraria users) has access to the .ssh dir and the authorized_keys file.

If that does not work, have you confirmed you can remote login to those users without authorized_keys? e.g. by giving a password?

  • Alright, so I ran cat on the users. Got the expected result of /home/USER/ for my privileged user and /bin/bash for the shell. For the other two users, their home directory is set to /opt/minecraft and /opt/terraria and both have /bin/bash shells so that's good I think. BUT I don't think I want to change the home directory of those users because that would change the way that a lot of their scripts operate and possibly open up a security hole (not sure, just guessing because that's why I separated the directories in the first place). And yet, I DID add the .ssh folder to those dirs and no dice
    – B-Dawg
    May 19, 2020 at 1:05
  • @BradynClaycomb I have edited my answer above with more info.
    – codlord
    May 19, 2020 at 10:43
  • Your solution worked! I just want to add the following: sshd DOES check the home directory of the user you are trying to login as for an authorized_keys file in the /.ssh/ directory. The keys of the machine you wish to allow access must be in THAT USER'S home authorized_keys file separate from the privileged user's keys file. I spent a lot of time modifying permissions to that original file thinking that sshd was always referencing that file for the keys when it in fact does not operate that way. Thanks again. I would give you more rep if I could.
    – B-Dawg
    May 21, 2020 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.