如何使用SSH登录Github并在命令行中创建新的存储库? [英] How do I use SSH to login Github and create a new repository in the command line?
问题描述
当使用如下所示的curl命令创建新的Github存储库时,它总是要求我输入密码.
When I create a new Github repository by using the curl command as shown below, it always asks me to enter the password.
curl -u "$(git config user.name)" https://api.github.com/user/repos -d "{\"name\":\"$1\"}" | grep -q "Bad credentials"
这是我的问题.如何通过SSH在命令行中使用ssh钥匙串使用SSH登录Github并创建新的存储库?
Here is my question. How to use SSH to login Github and create a new repository by using the ssh keychain in the command line?
推荐答案
请记住user.name
/user.email
配置设置与以下内容无关:
Keep in mind the user.name
/user.email
config settings have nothing to do with:
- 身份验证(仅用于提交作者身份)
- 您的GitHub帐户(您可以将user.name设置为与GitHub帐户名称相同,但user.name可以是您想要的任何名称)
按照 ElpieKay 的建议使用curl -H "Authorization: token MY_TOKEN_NUMBERS"
,您完全无需提供用户名" ;.
PAT(个人访问令牌)足以使GitHub对您进行身份验证.
Bu using a curl -H "Authorization: token MY_TOKEN_NUMBERS"
as recommended by ElpieKay, you bypass completely the need to provide a "user name".
The PAT (Personal Access Token) is enough for GitHub to authenticate you.
其中带有'ssh
'的任何内容(例如~/.ssh/id_rsa.pub
)仅适用于SSH URL(git@github.com:<me>/<myRepo>
),与基于HTTPS的curl
命令无关.
SSH仍然不适用于api.github.com
调用,如我在2013年提到的.
Anything with 'ssh
' in it (like ~/.ssh/id_rsa.pub
) would apply only for SSH URL (git@github.com:<me>/<myRepo>
) and has nothing to do with HTTPS-based curl
commands.
SSH would not apply to api.github.com
calls anyway, as I mentioned in 2013.
这篇关于如何使用SSH登录Github并在命令行中创建新的存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!