Laravel & Php

How to Set Up SSH Keys on Ubuntu


How to Set Up SSH Keys on Ubuntu

The chances are that you already have an SSH key pair on your Ubuntu client machine. If you generate a new key pair, the old one will be overwritten. To check whether the key files exist, run the following ls command:

ls -l ~/.ssh/id_*.pub

If the command returns something like No such file or directory, or no matches found, it means that the user does not have SSH keys, and you can proceed with the next step and generate SSH key pair. Otherwise, if you have an SSH key pair, you can either the existing ones or backup up the old keys and generate a new pair.

To generate a new 4096 bits SSH key pair with your email address as a comment, run:

ssh-keygen -t rsa -b 4096 -C "your_email@domain.com"

You will be prompted to specify the file name:

Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):

The default location and file name should be fine for most users. Press Enter to accept and continue.

Next, you’ll be asked to type a secure passphrase. A passphrase adds an extra layer of security. If you set a passphrase, you’ll be prompted to enter it each time you use the key to login to the remote machine.

If you don’t want to set a passphrase, press Enter.

Enter passphrase (empty for no passphrase):

To verify your new SSH key pair is generated, type:

ls ~/.ssh/id_*
/home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub

ssh Linux
Share with Friends

Like this chef? Share with friends..