Git push by ssh instead of http in order to avoid typing account and password

 Published On

Problem description

When pushing local repository to the corresponding remote one, I have to input the username and password of my github account. The reason is because I use git clone to establish the local repository. And git push will use http style by that style you need to input username and password very time. The solution is to replace the http remote origin by ssh remote origin.

The procudures of solution

First, check your remote link by

1
guiyang@guiyang-X450JF:~/my_site/guiyangxin.github.io$ git remote -v

You will get this result

1
2
origin https://github.com/GuiyangXin/guiyangxin.github.io.git (fetch)
origin https://github.com/GuiyangXin/guiyangxin.github.io.git (push)

Then remove this remote origin

1
guiyang@guiyang-X450JF:~/my_site/guiyangxin.github.io$ git remote rm origin

Copy the ssh origin from the repository on github

Finally, add the ssh remote origin

1
guiyang@guiyang-X450JF:~/my_site/guiyangxin.github.io$ git remote add origin git@github.com:GuiyangXin/guiyangxin.github.io.git

Tags: Git

Comments:

comments powered by Disqus