How to Set Up SSH Keys on Ubuntu 20.04

Setting up SSH keys on Ubuntu 20.04 involves a few steps. Here’s a guide:

  1. Check for Existing SSH Keys
    • Check for existing SSH keys:

      Run this command to see if you already have SSH keys:

                              
                                  ls ~/.ssh/id_*.pub
                              
                          

      If you see files named id_rsa.pub or id_dsa.pub, you have existing keys.

  2. Generate New SSH Key Pair (if needed)
    • Generate a new SSH key pair:

      If you don’t have keys or wish to create a new one, use:

                              
                                  ssh-keygen -t rsa -b 4096 -C "[email protected]"
                              
                          

      This command creates a new SSH key using the provided email. Press Enter to accept the default file location (~/.ssh/id_rsa) and optionally set a passphrase for added security.

  3. Add SSH Key to SSH Agent
    • Start the SSH agent:

                              
                                  eval "$(ssh-agent -s)"
                              
                          

    • Add your SSH private key to the SSH agent:

                              
                                  ssh-add ~/.ssh/id_rsa
                              
                          

      (Replace ~/.ssh/id_rsa with the path to your private key if it's different.)

  4. Copy the Public Key to the Remote Server
    • Copy the public key to the server:

      Use ssh-copy-id to copy your public key to the remote server. Replace username and remote_host with your server’s username and IP address or domain name:

                              
                                  ssh-copy-id username@remote_host
                              
                          

      Enter your password when prompted.

  5. Test SSH Connection
    • Connect to the server using SSH:

                              
                                  ssh username@remote_host
                              
                          

      If everything is set up correctly, it should log you in without asking for a password.

  6. Disable Password Authentication (Optional but Recommended for Security)
    • Edit SSH configuration file:

      Open the SSH configuration file using a text editor (like nano or vim):

                              
                                  sudo nano /etc/ssh/sshd_config
                              
                          

    • Disable Password Authentication:

      Find the line PasswordAuthentication and set it to no:

                              
                                  PasswordAuthentication no
                              
                          

    • Restart SSH service:

      Restart the SSH service to apply changes:

                              
                                  sudo systemctl restart sshd
                              
                          

That should get you set up with SSH keys on Ubuntu 20.04! Remember, using SSH keys for authentication is a secure method for accessing remote servers.

Streamline Data Serialization and Versioning with Confluent Schema Registry …

Using Confluent Schema Registry with Kafka can greatly streamline data serialization and versioning in your messaging system. Here's how you can set it up and utilize it effectively: you can leverage Confluent Schema Registry to streamline data seria …

read more

How To Restart Your Node.js Apps Automatically with nodemon

Restarting Node.js apps automatically during development is a common need, and nodemon is a popular tool for achieving this. Install nodemon,Navigate to your project directory,Start your Node.js application with nodemon, Custom Configuration (Optiona …

read more