I installed Ubuntu 22.04 and activated ssh service using
sudo apt install ssh
I tried to connect to my Ubuntu from my Windows using ssh via putty and it worked. putty asked to trust Ubuntu's key and everything is good.
But if I go to Ubuntu and try to see the public and private keys that were generated when installing the ssh service, they aren't in the ~/.ssh/
directory.
Can anyone explain it, please?
There is a difference between connecting with SSH and generating SSH public and private keys. Be aware that the terminology in your question (public and private keys, "id files",
~/.ssh/
) lead to thinking about user generated SSH keypairs.The directory you're referring to (
~/.ssh/
) is for user generated SSH keypairs,known_hosts
file etc., and installing SSH in itself will not generate a user keypair. If you want to connect with SSH keypairs from Windows, you need to do the following:Here is a Q&A on Superuser that details how to setup SSH keys on Windows for use with PuTTY, and another one about why and how the keys are stored.
However, if you're referring to the SSH host keys that are generated when installing SSH, those are located inside
/etc/ssh
, and can be listed with this command:The public host key is saved on the client machine (as
known_hosts
) to verify the identity of the remote machine and mark the connection as "trusted". On Ubuntu, known hosts are saved in~/.ssh/known_hosts
(refer to Superuser when it comes to Windows).