https://www.freecodecamp.org/news/the-ultimate-guide-to-ssh-setting-up-ssh-keys/
ssh-keygen
to create a new set of keys- Assign keys in a config file e.g.
~/.ssh/conf
- Only create new keys for new categories of servers, otherwise reuse the keys with conf settings.
Host <host alias>
HostName <domain of host>
User <username>
IdentityFile </path/to/private_rsa_file>
IdentityiesOnly yes
- Make sure
ssh-agent
is running. executeeval `ssh-agent -s`
from the command line. - Add the key to the repository with
ssh-add
. - Add the following lines to the config file:
Host *
AddKeysToAgent yes
copy your keys to your guest:
ssh-copy-id -i ~/.ssh/<rsa key>.pub <username>@<domain/ip>
Error: Warning: the ECDSA host key for '<domain>' differs from the key for the IP address '<ip address>'
Solution: ssh-keygen -R <domain|IP>