More detailed guide by Digital Ocean https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server
You will have two keys (in a pair)
Keep in mind you don't need a new pair for every server, you can use one pair for everything if you want (but if one gets compromised all of them do).
You can do this on a Windows machine if you have open-ssh installed.
ssh-keygen
Linux: ~/.ssh
mv example ~/.ssh
Windows: C:\Users\username\.ssh
Using scp
scp .\example.pub user@serverip:/home/user/.ssh
cat /home/user/.ssh/example.pub > /home/user/.ssh/authorized_keys
By default open-ssh is looking for id_rsa file. If you haven't changed your key's name, you can use
ssh user@serverip
If you changed your key's name, you need to specify what key you want to use using the -i parameter
ssh user@serverip -i /path/to/example
This will work on Linux and Windows, but if you need to use Powershell (which translates some unix commands to Windows APIs, so ~ is your home directory, even on Windows)
ssh [email protected] -i ~\.ssh\example
Edit /etc/ssh/sshd_config
sudo nano /etc/ssh/sshd_config
sudo systemctl restart sshd
Optional
sudo systemctl restart sshd
Now you must log in using your ssh key. Do not lose it.
Filezilla can't to sftp connect using the open-ssh key, so we need to convert it to a PuTTY compatible format.
winget install PuTTY.PuTTY
sftp://serverip
username
your SSH port (default is 22)
keep empty even if Filezilla asks you again