The authenticity of host can't be established

I’m using gitlab via ssh on Windows 10. After a while I somehow figured it out and it worked, which means I was able to create a new branch and even to upload code to this. This was last week when I was at home, since then I didn’t do anything related to this topic. Yesterday I had been in the company and since then nothing is working (I have no idea whether this might be related). When I try to git push or to ssh -Tvvv and so on I receive the following:

The authenticity of host ‘git.site.core.company.det (101.63.1.85)’ can’t be established.
ED25519 key fingerprint is SHA256:USgG8Fj7Qc50RYCs33DVXtZMyuD1Xd4UoXWgTm+8TJA.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory ‘/u/.ssh’ (Permission denied).
Failed to add the host to the list of known hosts (/u/.ssh/known_hosts).
git@git.site.core.company.det: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I can confirm that the public and private key are correct and the key is also provided on gitlab. I actually really don’t know what’s going on here. The only odd thing I see is that it is being tried to access

u/.ssh

while U:\ is the company network and there is no .ssh folder. I tried to change powershell such that it starts in the correct .ssh folder but the company policies do not allow this. And last week it somehow worked anyway but though this is the only thing that seems to be incorrect, e.g. as it is looking in the list of known hosts /u/.ssh/known_hosts while it should be looking in C:\Users\username\.ssh.

Can anybody help me in any way, please? Thanks a lot in advance!

P.S.: I changed the ip, key and names arbitrarily here.

OMG I cannot believe there is another company with such weird configs :rofl:

Basically, Windows for some reason, sometimes, bounds the command line / powershell environment to U:\ drive instead of C:\Users\YourUser . I’ve tried many things to fix this, but so far I haven’t figured out how to fix this permanently.

What I do every time some .git or .ssh config changes, I copy my whole .ssh folder from C:\Users\MyUser\.ssh into U:\.ssh and it fixes the issue.

Hope this works for you too! :slight_smile:

Otherwise I think you’ll have to bother your company admins…

1 Like

:smiley: :stuck_out_tongue:

I found a way to resolve this (though it has to be applied in each session) by setting the home variable accordingly to the current user. This is quite easy, e.g. in powershell enter

setx HOME "%USERPROFILE%

This solved everything. I guess this can also be automated via a script that is loaded on each startup. Maybe there is also a prettier solution but for not it’s working :slight_smile:

1 Like

Amazing! I will try this out as soon as this happens to me again. Can you maybe link any resources or whatever… how did you find this? Where can I read more about Powershell / CMD home/profiles?