Remove domain from ssh known hosts if you already have
|
|
Checking for existing SSH keys
Enter ls -al ~/.ssh
to see if existing SSH keys are present:
|
|
Check the directory listing to see if you already have a public SSH key.
By default, the filenames of the public keys are one of the following:
- id_dsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- id_rsa.pub
Generating a new SSH key pair
To create a new SSH key pair:
Generate a new ED25519 SSH key pair:
|
|
Or, if you want to use RSA:
|
|
The -C flag adds a comment in the key in case you have multiple of them and want to tell which is which. It is optional.
Adding or changing a passphrase
If, in any case, you want to add or change the password of your SSH key pair, you can use the -p flag:
|
|
or
|
|
Copying SSH key
Copy your public SSH key to the clipboard by using one of the commands below depending on your Operating System:
MacOS:
|
|
WSL / GNU/Linux (requires the xclip package):
|
|
Git Bash on Windows:
|
|
Note: If you opted to create an RSA key, the name might differ.
Test connecting via SSH
|
|
Example: To clone repository
|
|
Example: Reconfigure existing repositories to use SSH
List the existing remote repositories and their URLs with:
|
|
That command should output something like:
|
|
Change your remote repository’s URL with:
|
|
Git will use SSH
, instead of HTTPS
, to synchronize that local repository with its remote equivalent.