我的'Codenvy git config'没问题(可以通过菜单推送:git>远程>推送)。
现在我想通过命令配置'push'。
我尝试了一个简单的'git push',但它要求登录/密码。
管理:
git push https://login:pwd@myrepo.git
但是在命令行中使用明确的密码并不是一个好主意。
如何使用我的ssh密钥在codenvy中执行此命令?
答案 0 :(得分:1)
在.git / config中将远程repo URI更改为ssh,或者更改use git command。
git remote set-url origin sshAddress
答案 1 :(得分:1)
这取决于您的远程仓库(从CodeEnvy云会话访问)是否支持注册公共ssh密钥。
首先需要在CodeEnvy帐户中生成一个ssh私钥/公钥对(~/.ssh
)
正如本CodeEnvy forum thread(谈到远程AWS回购)所述,您需要注册公钥。
只有这样,一个ssh url不会要求用户名/密码(当它找不到公钥时,这是ssh回退机制)
对于http,如果CodeEnvy支持,则可能需要尝试credential helper。
答案 2 :(得分:1)
Codenvy基于Eclipse Che,并从该开源项目借用其git交互。您可以在此处找到有关添加凭据的文档:https://eclipse-che.readme.io/docs/git#ssh-key-management
但简短的回答是,您可以通过IDE的个人资料>将您的凭据添加到您的Codenvy帐户中。首选项菜单。
答案 3 :(得分:1)
这只是GITHUB !!
如果您想使用ssh,则必须为您的帐户设置ssh密钥和密码。 检查现有密钥
$ ls -al ~/.ssh
Keys将具有以下名称之一:
id_dsa.pub
id_ecdsa.pub
id_ed25519.pub
id_rsa.pub
如果您没有现有密钥,请使用以下内容生成密钥:
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
然后将密钥添加到ssh-agent
$ eval "$(ssh-agent -s)"
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
然后将您的密钥添加到GitHub
$ sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
$ xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
如果xclip不起作用,那么只需使用您喜欢的文本编辑器打开文件,然后使用默认的复制/粘贴工具来复制密钥。
登录GitHub,点击你的个人资料图片,然后点击设置。在右侧,单击SSH和GPG密钥。然后单击“新建SSH密钥”,键入描述性标题,将公钥粘贴到密钥字段中并提交。
要测试您的连接,请打开终端,然后输入
ssh -T git@github.com
你应该看到其中一个:
The authenticity of host 'github.com (192.30.252.1)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
或
The authenticity of host 'github.com (192.30.252.1)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?
输入是。然后你应该看到:
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.
现在可以使用ssh密码短语推送到GitHub:)
编辑:我也使用codenvy,这对我来说非常合适。另请参阅本指南:Connecting to GitHub with SSH