The private key works as a password and should be kept safe. Private key and public key of SSH are used to validate and establish an encrypted communication between a client and a remote machine over the internet.
To permanently add a private SSH key in Linux, you can follow these steps:
1. Open a terminal on your Linux machine.
2. Create a directory called .ssh in your home directory if it doesn't already exist. You can do this by running the following command:
mkdir -p ~ / .ssh
3. Copy your private SSH key file (usually named id_rsa) into the .ssh directory. If your key file has a different name, replace id_rsa with the appropriate filename in the following command:
cp / path / to / your / private / key / id_rsa ~ / .ssh /
4. Set the appropriate permissions on the key file by running the following command:
chmod 600 ~ / . ssh / id_rsa
5. Open the ~ / . ssh / config file in a text editor. If the file doesn't exist, create it:
nano ~ / . ssh / config
6. Add the following lines to the config file, replacing <key_filename> with the name of your private key file (e.g., id_rsa):
Host *
IdentityFile ~ / . ssh / <key_filename>
7. Save the changes and exit the text editor.
8. Now, whenever you use SSH to connect to a remote server, it will automatically use the private key specified in the config file.
By following these steps, you have permanently added your private SSH key in Ubuntu and configured it to be used automatically when connecting to remote servers.
Comments (0)