Home > Enterprise >  Git configuration on Ubuntu [22.04 LTS]
Git configuration on Ubuntu [22.04 LTS]

Time:05-26

I install git using

apt-get install git

this command. After that I configure git globally using

git config --global user.name = "MyUserName of Github"

and

git config --global user.email = "MyEmail of Github"

But when I want to clone or push any git repo, it will take again my username and password. But it says authentication failed again and again.

CodePudding user response:

You need to add an ssh key to your GitHub account. follow this link.

CodePudding user response:

It is always a good way to use ssh to do git related operations to your remote repo in your local system. I will tell you the step by step process so that you will not face this issue anymore:

Step1: Type these following commands in your command line

cd ~/.ssh

ssh-keygen -o -t rsa -C <you github id>

Ex:
ssh-keygen -o -t rsa -C "[email protected]"

Step2: Open github in your browser and go to settings and click on “ssh and gpgkeys” option and then create a new ssh key mention title and copy the output of the following command on linux terminal.

cat id_rsa.pub

And paste the output of above command in key area in github. Click on ADD ssh key and copy the ssh url of your repository and type the command: Ex:

git clone [email protected]:mcnz/lemfe 

Everytime you want to clone using your ssh, type the below command :

eval `ssh-agent`

CodePudding user response:

After 2021 August, github no longer support password, check link: https://github.blog/changelog/2021-08-12-git-password-authentication-is-shutting-down/

you should do what @Vikhyat say, use ssh key.

after you done, you can add below part on your ~/.ssh/config

Host github
  HostName github.com
  User git
  IdentityFile "~/.ssh/id_rsa"
  • Related