3

Possible Duplicate:
How to convert .ppk key to OpenSSH key *under Linux*?

(unix, here: ubuntu 10.4)

I know how to create ssh key pairs in unix (ssh-keygen) and how to do it in windows (puttygen). the missing part in my case would be how to use a keypair, generated in windows (puttygen), in a unix shell.

where do I need to put the public key, in this particular case, to use it as an ssh-key in git.

0

3 Answers 3

6

Depending on which key you need...

Private key – to log in from a Unix system into another Unix

You must first convert the key, using PuTTYgen, from PuTTY format to one OpenSSH can use.

  • In the Windows version of PuTTYgen, use the Conversions → Export OpenSSH key menu item;

  • in the Linux version, puttygen mykey.ppk -O private-openssh -o mykey.

Only public key – for logging in from Windows to Unix

See Daniel's answer.

4
  • Ok, I think I didn't make myself quite clear but found the solution: 1. start puttygen 2. load private key 3. Menu Conversions|Export OpenSSH key 4. Save somewhere, Open, Copy content to clipboard, paste on linux into file: $HOME/.ssh/id_dsa 5. copy content of text area "Public Key for pasting into OpenSSH authorized_keys file", paste on linux into file: $HOME/.ssh/id_dsa.pub
    – perler
    Feb 1, 2012 at 22:29
  • you can now use this SSH key from a linux shell to login into remote systems. side note: to seamlessly use git from windows putty in a linux shell to connect to git set these options in putty session: i.imgur.com/lh5LT.png (and you must put the public key in ~/.ssh/authorized_keys on the linux system and in git under public keys) (will put this as self answer, when I'm allowed, karma-wise)
    – perler
    Feb 1, 2012 at 22:29
  • @perler: Users are always allowed to answer questions, including their own. Also, the .pub file is optional. Feb 1, 2012 at 22:43
  • 1
    no you can't for 8 hours with karma below 100, big letters told me ;)
    – perler
    Feb 2, 2012 at 8:28
6

The Puttygen window contains a text area with the public key in the format expected by SSH.

Copy it, and add it to the file ~/.ssh/authorized_keys on the server on its own separate line. Make sure the file and the directory are not readable/writeable by group and others, i.e. run chmod go-rwx ~/.ssh ~/.ssh/authorized_keys.

Then the server will accept your login using the private key for authentication.

1
  • Definitely use this if connecting from Windows to Unix. Feb 23, 2013 at 3:32
3

Ok, I think I didn't make myself quite clear but found the solution:

  1. start puttygen
  2. load private key
  3. Menu Conversions|Export OpenSSH key
  4. Save somewhere, Open, Copy content to clipboard, paste on linux into file: $HOME/.ssh/id_dsa
  5. (optionally) copy content of text area "Public Key for pasting into OpenSSH authorized_keys file", paste on linux into file: $HOME/.ssh/id_dsa.pub

you can now use this SSH key from a shell to login into remote systems.

side note: to seamlessly use git from windows putty in a linux shell to connect to git set these options in putty session:

enter image description here

(and you must put the public key in ~/.ssh/authorized_keys, sure..)

3
  • Which is kind of what grawity and I wrote ;)
    – Daniel Beck
    Feb 2, 2012 at 17:24
  • you talked only about logging INTO a machine and grawity missed the important part of the question: where to put the files. thanks anyway..
    – perler
    Feb 2, 2012 at 21:21
  • 1
    (The answer being "absolutely anywhere".) Feb 7, 2012 at 15:53

Not the answer you're looking for? Browse other questions tagged .