Tag: ssh-keygen

  • How To Generate SSH Key Pair On Different Location In Linux

    How To Generate SSH Key Pair On Different Location In Linux

    What is SSH Key Pair & why it is important ?

    An SSH key pair is a way to keep your computer connections secure, like a secret code that only you can use. It consists of two parts: a “public key,” which you can share with others, and a “private key,” which you keep safe. When you use SSH, it makes sure no one can eavesdrop or mess with your information. It’s important because it helps protect sensitive data, like passwords, when you connect to other computers or websites online.

    By default SSH key pair is generated at location like /home/username/.ssh/ but with following method you can generate key at different location of your choice on Linux.

    Step 1 Install Open SSH on Linux

    # for Ubuntu: 
    
    sudo apt update && sudo apt install openssh-server
    
    # for Fedora:
    
    sudo dnf install openssh-server
    
    # for Arch Linux:
    
    sudo pacman -S openssh
    
    # for OpenSUSE/SUSE:
    
    sudo zypper install openssh

    Step 2 Crete folder at location of your choice

    mkdir -p /home/osbite.com/ssh_key

    Step 3 Change permission (give full permission to Owner only)

    chmod 700 /home/osbite.com/ssh_key

    Step 4 Generate SSH Key

    sudo ssh-keygen -t rsa -b 4096 -C "Key for Server 51" -f /home/osbite.com/ssh_key/my_key

    This will do following tasks:

    1. Generate SSH key pair at location – /home/osbite.com/ssh_key/
    2. Will generate keys with name my_key (private key) & my_key.pub (public key)