Ubuntu SSH setup for Git | Tech, Trading, and Business Systems
  1. Generate key

    ssh-keygen -t <key_name> -C "[email protected]"

  2. add the key to ssh agent

    • start agent in the background

      eval "$(ssh-agent -s)"

    • add the private key

      ssh-add ~/.ssh/<key_name>

  3. make sure the public key is added to github

    Github Guide to Adding SSH Keys


To automatically start the agent and register the key on login, add the following to ~/.bashrc

# Start SSH agent if not running and add keys
if [ -z "$SSH_AUTH_SOCK" ]; then
    eval "$(ssh-agent -s)" > /dev/null 2>&1
fi

# Add your GitHub private key
if ! ssh-add -l | grep -q "github"; then
    ssh-add ~/.ssh/your_github_key 2>/dev/null
fi

References

Github Guide for Setting up SSH