Linux: Creating a ssh keypair with ssh-keygen

Hi,

ssh-keygen can be used to generate a new ssh key pair.

To generate a new pair use the following command line which store both, private an d public key, in $HOME/MyGeneratedKeys (default directory $HOME/.ssh).

michael@debdev ~ # mkdir MyGeneratedKeys 
michael@debdev ~ # ssh-keygen -b 2048 -t rsa -f $HOME/MyGeneratedKeys/id_rsa -C "My ssh key"
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/michael/MyGeneratedKeys/id_rsa.
Your public key has been saved in /home/michael/MyGeneratedKeys/id_rsa.pub.
The key fingerprint is:
SHA256:4fcRXik1VAyxoVAvLZTb4FvjjI7yGIQUQ3w7VCmF6lI My ssh key
The key's randomart image is:
+---[RSA 2048]----+
|     o+  ++oooB=.|
|      .o= .oo= =.|
|      .+.o .*+*  |
|     .Eoo. .o*+  |
|     o. S.. o* . |
|    . .. . .o.o  |
|     .  .  o.    |
|        .o. .    |
|        .o.      |
+----[SHA256]-----+

To use it start the ssh-agent and add the keys. ssh-agent prints out the socket (SSH_AUTH_SOCK) and the ssh-agent PID (SSH_AGENT_PID) which have to set as environment variables. eval combined with ssh-agent does this in one step.

michael@debdev ~ # eval `ssh-agent`
michael@debdev ~ # set|grep SSH_
SSH_AGENT_PID=3899
SSH_AUTH_SOCK=/tmp/ssh-pL4CiUVIdGK7/agent.3898
michael@debdev ~ # ssh-add /home/michael/MyGeneratedKeys/id_rsa

If you want to use the new key with putty you have to convert it with puttygen.

Load the private key

Note: Set filter to all files *.*

enter passphrase

And save it as putty key

Michael

Advertisment to support michlstechblog.info

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress