使用 ssh-key 在没有密码的情况下推送到 GitHub [英] Push to GitHub without a password using ssh-key

查看:21
本文介绍了使用 ssh-key 在没有密码的情况下推送到 GitHub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成了一个没有密码的 SSH 密钥对,并将公钥添加到了 GitHub.

I generated an SSH key pair without a password and added the public key to GitHub.

连接

user@dev:/var/www/project# ssh -T git@github.com
Hi User! You've successfully authenticated, but GitHub does not provide shell access.

成功了,当我重命名密钥时,它失败了.

was successful and when I rename the key, it fails.

但是当我想推送我的更改时,它仍然会询问我的用户名和密码组合.

But when I want to push my changes, it stills ask me for my username and password combination.

有没有办法不用密码推送?

Is there a way to push without a password?

推荐答案

如果它要求您提供用户名和密码,则您的远程源指向的是 HTTPS URL 而不是 SSH URL.

If it is asking you for a username and password, your origin remote is pointing at the HTTPS URL rather than the SSH URL.

将其更改为 ssh.

例如,像 Git 这样的 GitHub 项目将有一个 HTTPS URL:

For example, a GitHub project like Git will have an HTTPS URL:

https://github.com/<Username>/<Project>.git

和 SSH 之一:

git@github.com:<Username>/<Project>.git

你可以这样做:

git remote set-url origin git@github.com:<Username>/<Project>.git

更改网址.

这篇关于使用 ssh-key 在没有密码的情况下推送到 GitHub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆