git push不需要输入密码

使用SSH key即可搞定

以github为例


1.首先,在github上创建一个repository,如上图:会有一个SSH ,复制它

2.如果以前https link进行推送的话,则需要先删除

git remote -v  查看使用的是https还是ssh

git remote rm origin

重新关联一下

git remote add origin +复制的SSH  (git@github.com:chengandguo/abc.git 就是这样的格式)

3.如果本地没有创建SSH key的话

ls -al ~/.ssh    查看本地有无ssh key

没有就ssh-keygen   生成一个,一路回车即可

并按如下方法添加

Ensure ssh-agent is enabled:

If you are using Git Bash, turn on ssh-agent:

    • # start the ssh-agent in the background
      eval "$(ssh-agent -s)"
      Agent pid 59566
    • If you are using another terminal prompt, such as Git for Windows, turn on ssh-agent:
    • # start the ssh-agent in the background
      eval $(ssh-agent -s)
      Agent pid 59566
      
  1. Add your SSH key to the ssh-agent. If you used an existing SSH key rather than generating a new SSH key, you'll need to replace id_rsa in the command with the name of your existing private key file.

    $ ssh-add ~/.ssh/id_rsa
4.登录到Github上,在settings设置下有一个SSH 栏目,进去把刚才生成的id_rsa.pub  (默认地址:C:\Users\您的用户名\.ssh)里的内容添加进去即可


5.到此就大功告成了,如果你换个机器,一样生成个SSH key添加一遍即可


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值