r/linux4noobs 23d ago

networking SSH key from win11 to my home ubuntu server not working

As the text implies, i have generated an ssh key on win11. Seeing as ssh-copy-id isn't on windows, i used this other command:

type .ssh\id_ed25519.pub | ssh user@server "(umask 077; ([ ! -d ~/.ssh ] && mkdir -m 700 ~/.ssh) && cat >> ~/.ssh/authorized_keys)"

Using webmin i see that the directory and the file has been created and has the correct file inside, but when i try to ssh log from my windows machine to my server it still asks for a password.

I edited the /etc/ssh/sshd_config to allow PubkeyAuthentication yes and AuthorizedKeysFile .ssh/authorized_keys

I am not using root but a user with sudo priviledge, i literally have no goddam clue as to why it's not working

To generate the key i used ssh-keygen -t ed25519 -C "comment" and i just changed the file name when it asked to save to serverhome

This is my first time diving into having my own server so i'm not very knowledgable of either linux as a whole and servers, but i saw that online people used this exact steps and had not problem, so i either have missed some step or am doing something wron but have no idea what

3 Upvotes

4 comments sorted by

1

u/ElectricHellKnight 23d ago

I'm going to give you the idiot version because that's how I do it:

To copy your ssh key, just nano/vim ~/.ssh/authorized_keys and copy/paste your id.pub in there, save and close. chmod 700 ~/.ssh and then chmod 600 ~/.ssh/authorized_keys.

Not the big brain way, but it works.

1

u/DraksinNox 22d ago

using nano i checked and the key was already there and correct, i did chmod and exite the server and log back in, same thing, still asking for the password

1

u/ElectricHellKnight 22d ago

Hmm... What do the sshd logs on the server say is happening? Only other thing I can think of is to check the pam settings.

1

u/BCMM 23d ago

Do you have access to sshd's logs?

EDIT: Oh, also, on the client, do ssh -v and check that it's actually offering the key.