Export GitHub acceptable SSH key in OpenSSH format from PuTTYgen - github

I am adding an SSH key to my GitHub account.
To do that, I open PuTTYgen and press the button "Generate".
When the key pair has been generated, I use the menu and open "Conversions" and "Export OpenSSH Key".
Then I go into GitHub, settings SSH and GPG Keys, press "new SSH key" and paste the contents of the generated file into the textbox (adding the title "github").
But I get a message about an invalid key.
Key is invalid. You must supply a key in OpenSSH public key format.
Why?
I have also tried to
Select "force new file format" and
the normal "save public key" button
A solution would be to let GitHub create the key, but I have not seen how.

Use the public key in the format shown in the PuTTYgen's "Public key for pasting into OpenSSH authorized_keys file" box.

Related

Key saved but not correctly

I was able to save my key on GitHub. (It does not end in .pub).
When testing if this was done correctly and using the 'ssh -T git#github.com' code, there is something off.
The terminal asks me if I want to continue, and I wrote 'yes', then a pop-up box asking for a password came up... I input nothing and clicked "unlock", which resulted in the bottom code saying "Permission denied". (see screenshot).
I'm not sure what to do here--I have followed the instructions multiple times.
Please let me know how to fix this.
When you add your SSH key to GitHub, that would be the one ending with .pub.
Then, double-check the correct private key is used with:
ssh -Tv git#github.com
It would ask for a passphrase only if you have created the private key with a passphrase.
If you did, make sure to add your key to the agent first.
Check also your ~/.ssh permissions.

unable to get SSH keys working between sourcetree and github

I was able to create a key and connect to github following these instructions via the command prompt successfully:
https://help.github.com/articles/generating-ssh-keys
However, when I try to connect via Sourcetree and putty I cannot. I've tried:
generating a new key with the putty key generator (SSH-2 RSA)
entering a passphrase
saving the private key
saving the public key and adding a .pub extension
copying/pasting the key from the putty key generator window into github
attemping to refresh branches on a pull from my private github repository from my local repo using the SSH clone URL I got from github
I also tried opening the key generated from the github command line instructions and it wanted me to convert it to a putty-type key which I did and saved off, tried with that one. Also no luck.
What am I doing wrong?
In order to get it worked I ended up going to Tools -> Options -> SSH Client and changing it to OpenSSH. I generated and uploaded several different types of keys trying to get it work as well but I think this is what finally did it.
In my case, I needed to switch to a git or ssh based repo path rather than the https based repo path. This causes SourceTree to switch to SSH based authentication.
This setting can be found at Repository => Repository setting => Paths
Example:
Correct repo paths
git#github.com:<username>/<reponame>.git
or
ssh://git#github.com/<username>/<reponame>.git
(Note: if you are working with a repo that isn't yours, replace username with organization name)
Wrong repo path
https://github.com/<username>/<reponame>.git
HTTPS repo paths result in SourceTree trying to be extra smart and failing spectacularly. You get prompted for a username/password GUI dialog which will never work if you have 2 factor authentication enabled.
To login to Github account using SourceTree you may use access tokens. To create an access token follow these steps.
Go to Settings
Select Developer settings from left pane
Select Personal access token
Click on Generate new token button
Give it a name
Select scopes and generate token (save this token somewhere safe because you won't be able to access this token again)
Then in SourceTree app follow these steps (for Mac users, not sure about the other platforms)
Go to Preferences->Accounts
Click add button
Select GitHub from Host dropdown
Choose Basic from Auth Type dropdown and HTTPS from Protocol dropdown
Enter your GitHub username in Username field
Paste the access token generated in the previous process in the Password field
Click save and you're done
For Mac versions of SourceTree the Tools menu does not exist.
However, you can add the ssh key to your keychain in Mac OS. See: https://superuser.com/questions/879050/sourcetree-ssh-options-on-os-x
On Mac OSX, the native SSH client can use the built-in keychain directly. To add your private key to the keychain simply use the command:
ssh-add -K /path/of/private/key
As an example if your private key is stored at ~/.ssh and is named id_rsa, you would use the command:
ssh-add -K ~/.ssh/id_rsa
You will then be prompted for your passcode, which will be stored in your keychain. After this you should be ready for a password-less login.
You may want to consider switching from OpenSSH to Putty / Plink and use embedded Git instead of Git provided by host OS. Making ssh-agent work on Windows is a bit more complicated than clicking it out straight from the SourceTree and PuttyGen.
If you want to still use terminal to configure SSH and start ssh-agent please see bottom two steps.
For Sourcetree on MacOS I had to change from OAuth to Basic authentication, use "git" as the username (not my GitHub username), and generate the SSH key and input it into GitHub. Only then could I clone a GitHub repo via SSH in Sourcetree.

how can i connect GitHub through putty

I had follow the steps given in so many docs like this one,
after creating a key i pasted it in my GITHUB account>account settings>SSH key.
When I add it there it shows a message:" key is invalid".
I really don't link the tutorial part which mentions:
Save the private key somewhere with a passphrase and then copy the public key text to the clipboard.
"somewhere"? ssh keys must be saved in %HOME%\.ssh.
(Note: %HOME% doesn't exists in windows, and default to %USERPROFILE%)
Make sure to have your public and private keys saves in:
%USERPROFILE%\.ssh\id_rsa
%USERPROFILE%\.ssh\id_rsa.pub
set HOME=%USERPROFILE%
plink git#github.com

Unable to use key file Eclipse

I setup public key access to my server via ssh. I have a .ssh folder on my local windows computer. I configured ssh to add the private key using the ssh-add <directory> command. I am able to successfully connect to my server using windowspowershell. The chmod and Chown of the .ssh directory and authorized file are configured correctly on my server. sshd_config is configured correctly and points to the correct key.
The connection works perfectly with shell so there is no problem on my server. But with Eclipse, and its plugin in particular, Egit, I keep getting a Unable to use key file <directory of the key file I loaded into eclipse the same one used by ssh error every time I try to push my revision commits to my git repository on the server. I went to Pref > General > Network > SSH2 and added the right private key, the ssh2 home directory is set correctly too, in fact the public an private key were both generated using the key management tab and loaded into my server.
My windows permissions on that folder and those keys is set to allow all users to do everything just for good measure.
Now one clue is, the known hosts tab has a host fingerprint that does not match the fingerprint of my key. My key is something like f1:19: etc and the hosts fingerprint is different. I hope I can fix this soon. Any suggestions would be great.
ssh-add -l = two private keys that I am using. So its not this.
Another clue is, after going into my putty program and changes the private key that it ses suddenly is i try to connect to ssh with a key acces in eclipse the error it throws shows reflects the same key that I just changed in putty!! Somehow eclipse seems to be using putty for public key access. How do I stop this?!
Okay here's the solution. For whatever reason Egit uses putty to connect to ssh using the configuration putty is set to use to access a server with a public key. The way you fix this is to make sure putty is able to connect to the server using a public key. If it can't then try this:
Download puttygen
Generate a rsa key using either ssh shell or the key management tab on eclipse. Do not generate a key using puttygen. For whatever reason it never worked for me.
Load the private key you generated (not generated with puttygen) into puttygen and then save as a putty private key (.ppk)
Go to eclipses key management tab and set it to recognize the new .ppk private key file
Finally go to putty, and create your servers profile by assigning the address and then go to auth and load the .ppk file. DISABLE pageant.
Save and attempt to connect to server using the key and if successful then congratulations Egit and Eclipse will now be able to make connections using keys.

GnuPG: "decryption failed: secret key not available" error from gpg on Windows [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Environment: HP laptop with Windows XP SP2
I had created some encrypted files using GnuPG (gpg) for Windows. Yesterday, my hard disk failed so I had reimage the hard disk. I have now reinstalled gpg and regenerated my keys using the same passphrase as earlier. But, I am now unable to decrypt the files. I get the following error:
C:\sureshr>gpg -a c:\sureshr\work\passwords.gpg
gpg: encrypted with 1024-bit ELG-E key, ID 279AB302, created 2008-07-21
"Suresh Ramaswamy (AAA) BBB"
gpg: decryption failed: secret key not available
C:\sureshr>gpg --list-keys
C:/Documents and Settings/sureshr/Application Data/gnupg\pubring.gpg
--------------------------------------------------------------------
pub 1024D/80059241 2008-07-21
uid Suresh Ramaswamy (AAA) BBB
sub 1024g/279AB302 2008-07-21
AAA = gpg comment
BBB = my email address
I am sure that I am using the correct passphrase. What exactly does this error mean? How do I tell gpg where to find my secret key?
Thanks,
Suresh
You need to import not only your secret key, but also the corresponding public key, or you'll get this error.
when reimporting your keys from the old keyring, you need to specify the command:
gpg --allow-secret-key-import --import <keyring>
otherwise it will only import the public keys, not the private keys.
Yes, your secret key appears to be missing. Without it, you will not be able to decrypt the files.
Do you have the key backed up somewhere?
Re-creating the keys, whether you use the same passphrase or not, will not work. Each key pair is unique.
workmad3 is apparently out of date, at least for current gpg, as the --allow-secret-key-import is now obsolete and does nothing.
What happened to me was that I failed to export properly. Just doing gpg --export is not adequate, as it only exports the public keys. When exporting keys, you have to do
gpg --export-secret-keys >keyfile
One more cause for the "secret key not available" message: GPG version mismatch.
Practical example: I had been using GPG v1.4. Switching packaging systems, the MacPorts supplied gpg was removed, and revealed another gpg binary in the path, this one version 2.0. For decryption, it was unable to locate the secret key and gave this very error.
For encryption, it complained about an unusable public key.
However, gpg -k and -K both listed valid keys, which was the cause of major confusion.
The resolution to this problem for me, was to notify the sender that he did use the Public key that I sent them but rather someone elses. You should see the key that they used. Tell them to use the correct one.