3

My 'Codenvy git config' is ok (can push through menu: git > remote > push).

Now I would like to configure a 'push' through command.

I tried a simple 'git push' but it asks for login / password.

Managed to do it with :

git push https://login:pwd@myrepo.git

But having clear password in the command line is not a good idea.

How can I do this command in codenvy with my ssh key?

Tyvain
  • 2,640
  • 6
  • 36
  • 70

4 Answers4

1

Change the remote repo URI to ssh in .git/config, or you change use git command.

git remote set-url origin sshAddress

detail see here

chaoluo
  • 2,596
  • 1
  • 17
  • 29
1

It depends if your remote repo (accessed from your CodeEnvy cloud session) supports registering a public ssh key.

You would need first to generate an ssh private/public key pair in your CodeEnvy account (in ~/.ssh)
The, as describe in this CodeEnvy forum thread (speaking about a remote AWS repo), you would need to register your public key.

Only then, an ssh url would not ask for a username/password (which is the ssh fallback mechanism when it does not find the public key)

For http, you might need to try a credential helper, if CodeEnvy supports one.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Codenvy is based on Eclipse Che and borrows its git interaction from that open source project. You can find docs on adding credentials here: https://eclipse-che.readme.io/docs/git#ssh-key-management

But the short answer is that you can add your credentials into your Codenvy account through the IDE's Profile > Preferences menu.

Brad Micklea
  • 257
  • 1
  • 2
1

THIS IS FOR GITHUB ONLY!!

If you would like to use ssh, then you will have to set up an ssh key and passphrase for your account. Check for existing keys

$ ls -al ~/.ssh

Keys will have one of these names:

id_dsa.pub

id_ecdsa.pub

id_ed25519.pub

id_rsa.pub

If you don't have an existing key, generate one with:

$ 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]

Then add your key to the ssh-agent

$ eval "$(ssh-agent -s)"
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa

Then add your key to 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

If xclip doesn't work, then just use your favorite text editor to open the file and use your default copy/paste tools to copy the key.

Login to GitHub, click on your profile pic, then click settings. On the right, click SSH and GPG keys. Then click New SSH Key, type in a descriptive title, paste the public key into the key field and submit.

To test your connection, open your Terminal, and type in

ssh -T git@github.com

You should see one of these:

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)?

or

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)?

Type in yes. Then you should see:

Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

You can now push to GitHub by using your ssh passphrase :)

EDIT: I also use codenvy, this worked perfectly for me. See also this guide: Connecting to GitHub with SSH

Pranav A.
  • 460
  • 1
  • 5
  • 18