This is to set up the key once, and then don't need to enter the passphrase every single time:
Use an ssh-agent in WSL with your ssh setup from windows 10 | by Philipp Scheit | Medium
Create new key pair
Use the ssh-keygen command to generate a public and private authentication key pair. Authentication keys enable you to connect to a remote system without needing to supply a password each time that you connect.
To create a public and private SSH2 RSA key pair. To create an SSH key pair by using an algorithm other than the default RSA algorithm, use the -t option. Possible values that you can specify include the following: dsa
, ecdsa
, ed25519
, and rsa
. In this case, I use ed25519 algorithm.
ssh-keygen -t ed25519
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_ed25519
Your public key has been saved in /home/user/.ssh/id_ed25519.pub
Enter file in which to save the key (/home/user/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_ed25519
Your public key has been saved in /home/user/.ssh/id_ed25519.pub
Copy old key pair to new system (new WSL/Ubuntu/laptop)
If you copy the old key pair to the new system, you need to change the permission in order to have it work.
Run this command:
How to check the permissions:
ls -ld ~/.ssh
ls -l ~/.ssh
What the permissions should look like:
File/Folder | Expected Permissions | Command to Fix |
---|---|---|
~/.ssh/ | drwx------ (700) | chmod 700 ~/.ssh |
id_rsa | -rw------- (600) | chmod 600 ~/.ssh/id_rsa |
id_rsa.pub | -rw-r--r-- (644) | chmod 644 ~/.ssh/id_rsa.pub |
authorized_keys (on server) | -rw------- (600) | chmod 600 ~/.ssh/authorized_keys |
No comments:
Post a Comment