Tuesday, January 27, 2015

How to use open ssh key?

The OP already has a key, it is a .ppk which is a format used by Putty. The OP has converted it to an open ssh key already.
To use the key,
First, by default, the key should stored in ~/.ssh with permissions of 600 as outlined above.
Second, you have two options to use the key.
Option 1 - Use putty - You can install and use putty in Linux. Putty can use the key in either format.
Option 2 - Use ssh on the command line
ssh -i ~/.ssh/your_key user@server
If you have any errors , post them here.

How to establish ssh key pair when “Host key verification failed”

I have set up ssh key pairs between my desktop and two servers, and from the servers to my desktop, but after reinstalling the OS on my desktop, I can't re-establish the keypair going into my desktop by this:
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t 
ssh-copy-id username@server
I get the following error:
(names in italics changed to protect the innocent My desktop is Ubuntu, and I can't find the answerhere)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is ab:cd:ef:gh Please contact your system administrator. Add correct host key in /home/user/.ssh/known_hosts to get rid of this message. Offending key in /home/user/.ssh/known_hosts:1 RSA host key for user.server has changed and you have requested strict checking. Host key verification failed.

Solution

ssh-keygen -R hostname
This deletes the offending key from the known_hosts
The man page entry reads:
-R hostname Removes all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts (see the -H option above).

How to convert .ppk key to OpenSSH key under Linux (ubuntu)

Do it with Putty.
  • Linux: with your package manager, install PuTTY (or the more minimal PuTTY-tools):
    • Ubuntu sudo apt-get install putty-tools
Place your keys in some directory, e.g. your home folder. Now convert the PPK keys to SSH keypairs:cache search
To generate the private key:
cd ~
puttygen id_dsa.ppk -O private-openssh -o id_dsa
and to generate the public key:
puttygen id_dsa.ppk -O public-openssh -o id_dsa.pub
Move these keys to ~/.ssh and make sure the permissions are set to private for your private key:
mkdir -p ~/.ssh
mv -i ~/id_dsa* ~/.ssh
chmod 600 ~/.ssh/id_dsa
chmod 666 ~/.ssh/id_dsa.pub
If you have already tried to perform a 'git clone' operation you might need to do this also
chmod 666 ~/.ssh/known_hosts