I currently have to ssh with user FOO then sudo to user BAR.

I would like to ssh using a public key, but on the remote system there is no home directory for user FOO, so obviously no .ssh/authorized_keys. Where can I put my public key ?

The /home directory is empty, so it seems no home directories are created for any user, and I don't have root on that system.


  • Not an answer, just a note: You will need the private key. Commented Feb 8, 2018 at 12:32

2 Answers 2


Assuming your username is testssh:

  • create /etc/ssh/authorized_keys_testssh and put your key there
  • add the following in /etc/ssh/sshd_config:
Match User testssh
    AuthorizedKeysFile  /etc/ssh/authorized_keys_%u

and restart sshd. Your user will be able to ssh with his private key.

  • 2
    It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
    – igal
    Commented Feb 8, 2018 at 13:43
  • 1
    indeed, this cannot be achieved without involving the admin (root).
    – tonioc
    Commented Feb 8, 2018 at 15:38
  • 2
    But the question specifically states that the user does not have root access.
    – igal
    Commented Feb 8, 2018 at 17:02
  • 1
    Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
    – ccc
    Commented Feb 9, 2018 at 13:52

Short Answer

You probably can't - talk to your sysadmin.

Longer Answer

First of all, the fact that the /home directory is empty (and even if it doesn't exist) doesn't necessarily mean that your user doesn't have a home directory. You can try looking at the value of the HOME environment variable:

$ echo $HOME

or use the getent command:

$ getent passwd username
username:*:1001:1001:User Name:/path/to/nonstandard/homedirectory:/bin/bash

If it turns out that your user really does not have a home directory then it still might be possible to use a public key if your server administrator has set a nonstandard location for your authorized_keys file.

Assuming you're using OpenSSH, the location of the authorized_keys file can be specified by the AuthorizedKeysFile keyword in the sshd_config configuration file. Consult the documentation for more information:

The default value is ~/.ssh/authorized_keys. You'll have to look at the settings in /etc/ssh/sshd_config to see if the default is being over-ridden. Since you don't have root access you'll probably have to ask your system administrator for help if you want to make any changes.

If it turns out that you don't have a home directory, that your system administrator hasn't configured a different location for your authorized_keys file, and you don't have administrative privileges on your machine, then you probably won't be able to use key-based authentication - talk to your sysadmin.

  • Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
    – ccc
    Commented Feb 9, 2018 at 14:04
  • The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
    – igal
    Commented Feb 9, 2018 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .