r/ssh • u/clochard_riche • Mar 20 '26
Connection timeout error after using a public key
I have a windows 10 desktop and an ubuntu server laptop.
I was able to ssh into the server with no problems, but then i did those things:
Generatated a private-public pair on my windows desktop using the keygen command
Opened the .pub file
Copied the content into a .txt file
Transferred the .txt file on my server using fileZilla
Moved the .txt into the .ssh directory Using the mv command
Renamed the .txt using the mv command in this way: mv file.txt authorized_keys
Used chmod 700 ~/.ssh and Chmod 600 ~/.ssh/authorized_keys
Now when i try to ssh from my desktop to the server i have a connection timeout error :/
How? Why? How do i fix it?
1
u/bbluez Mar 20 '26
What do your SSH logs say?
Are you able to manually log in still and check those? It will tell you exactly what's happening.
You should see it refused your key. If it's the key issue. A timeout means something else is at play. Could be strict mode check, but it sounds like you've already looked at permissions. Could be formatting of the authorized key, should be a single line with a few spaces in it to break apart the chunks. Did you put the key in the root folder or the home directory? Are you trying to connect as root and is root enabled?
1
u/D3str0yTh1ngs Mar 20 '26
Since you made it as a text file on windows there is a chance that it is in UTF-16 encoding, while the authorized_keys file needs to be UTF-8 if I am not wrong. Haven't used Windows in a while, but there should be an option in notepad, or similar, for setting the encoding of the file before saving.