openssh cannot create directory /home/local/<my username>/.ssh

Viewed 344

When I try ssh [IP] openssh warns Could not create directory '/home/local/[my username]/.ssh'.

I do have an .ssh directory, in another path, in my actual home directory, at /home/[myusername]/.ssh.

Why is openssh adding a local to that home path? That path does not exist. I'm on Ubuntu 16.04 my $HOME is set properly, i.e. /home/[my username].

I can't find where openssh is configured to even look for that 'local' path. I've grep'ed for local under /etc/ssh/ which did not return anything.

Update:

getent passwd $USER shows the wrong home path, with the 'local' in the path. Apparently openssh uses the home path as output by that command, instead of the $HOME environment variable to find the home directory. I can't just edit /etc/passwd as $USER comes from an LDAP. Not sure if my IT department can edit my home path in LDAP, is there a way I can tell openssh what home path to use, i.e. $HOME not getent passwd $USER?

1 Answers

Apparently openssh uses the home path as output by that command

I use quite often openssh with HOME set to a different folder than the default one, and it works without any issue.
Check your other environment variables to see if there are other mentions of the wrong path in one of them.

As the OP comments, the issue was in the LDAP managing the account.

It is true you can store ssh keys in LDAP, which allows SSH connection from any server where you are logged on (since your keys are fetched from LDAP)

Example of LDAP schema:

In /usr/local/lib/ldap/schema/openssh-ltk.ldif:

    dn: cn=openssh-lpk,cn=schema,cn=config
    objectClass: olcSchemaConfig
    cn: openssh-lpk
    olcAttributeTypes: ( 1.3.6.1.4.1.24552.500.1.1.1.13 NAME 'sshPublicKey'
        DESC 'MANDATORY: OpenSSH Public key'
        EQUALITY octetStringMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
    olcObjectClasses: ( 1.3.6.1.4.1.24552.500.1.1.2.0 NAME 'ldapPublicKey' SUP top AUXILIARY
        DESC 'MANDATORY: OpenSSH LPK objectclass'
        MAY ( sshPublicKey $ uid )
    )
Related