Search code examples
ubuntugithubcredentials

How to save the login credentials for github on Linux?


I'm using git on a Ubuntu/Debian machine. I know how to config user informations (name, mail) for repositories. But with a private github repository, it always require a token each time I push or pull to/from remote. enter image description here This is repetitive, so I wonder if there's a solution to this. I think that the token can ben save somewhere and automatic login like the github desktop on Window.

I searched google but didn't find out solution.

Many thanks for suggestions!


Solution

  • Following the official instructions of Github on SSH key worked for me It contains 2 steps:

    1. Generating a new SSH key
      ssh-keygen -t ed25519 -C "[email protected]"
      > Generating public/private ALGORITHM key pair.
      > Enter a file in which to save the key (/home/YOU/.ssh/id_ALGORITHM):[Press enter]
      > Enter passphrase (empty for no passphrase): [Type a passphrase]
      > Enter same passphrase again: [Type passphrase again]
      eval "$(ssh-agent -s)"
      ssh-add ~/.ssh/id_ed25519
      
    2. Adding the new SSH key to your GitHub account
      cat ~/.ssh/id_ed25519.pub
      # Then select and copy the contents of the id_ed25519.pub file
      # displayed in the terminal to your clipboard
      

    enter image description here