SSH: Difference between revisions

From My Wiki
Jump to navigation Jump to search
Created SSH Keys section with OpenSSH and Puttygen methods for Linux.
 
Using OpenSSH: corrected chown to chmod for Using OpenSSH
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
  ssh-keygen -t rsa -b 4096 -C "Your comment here" -f ~/.ssh/$hostname2.key
  ssh-keygen -t rsa -b 4096 -C "Your comment here" -f ~/.ssh/$hostname2.key
Make sure it has safe permissions:
Make sure it has safe permissions:
  chown 600 $hostname*.key
  chmod 600 $hostname*.key
Then for the user you want to log in as, copy the .pub file's contents to the user's .ssh/authorized_keys file. It also needs to have 600 permissions.
Then for the user you want to log in as, copy the .pub file's contents to the user's .ssh/authorized_keys file. It also needs to have 600 permissions.
==Using puttygen==
 
==Using Puttygen==
===Linux===
===Linux===
<p>Install the putty-tools package if you haven't already. </p>
Create the key:
Create the key:
  puttygen -t ed25519 -C "Your comment here" -o ~/.ssh/$hostname.ppk
  puttygen -t ed25519 -C "Your comment here" -o ~/.ssh/$hostname.ppk
Line 18: Line 20:
  puttygen -L ~/.ssh/$hostname.ppk
  puttygen -L ~/.ssh/$hostname.ppk
Then for the user you want to log in as, copy the output to the user's .ssh/authorized_keys file. It also needs to have 600 permissions.
Then for the user you want to log in as, copy the output to the user's .ssh/authorized_keys file. It also needs to have 600 permissions.
==Converting Between the Two==
Let's say you have a public key file in OpenSSH2's native format (like PuTTY generates). Here's how to create one:
puttygen -O public testkeyforwaypoint.ppk > testkey1a.pub
You can convert it like this:
ssh-keygen -i -f testkey1a.pub > testkey2.pub
However, the converted key will have the comment stripped. Otherwise, it should match the OpenSSH private key output of the original.

Latest revision as of 23:02, April 21, 2023

SSH Keys

Using OpenSSH

Create a key:

ssh-keygen -t ed25519 -C "Your comment here" -f ~/.ssh/$hostname.key

Or, in RSA format:

ssh-keygen -t rsa -b 4096 -C "Your comment here" -f ~/.ssh/$hostname2.key

Make sure it has safe permissions:

chmod 600 $hostname*.key

Then for the user you want to log in as, copy the .pub file's contents to the user's .ssh/authorized_keys file. It also needs to have 600 permissions.

Using Puttygen

Linux

Install the putty-tools package if you haven't already.

Create the key:

puttygen -t ed25519 -C "Your comment here" -o ~/.ssh/$hostname.ppk

Or, in the RSA format:

puttygen -t rsa -b 4096 -C "Your comment here" -o ~/.ssh/$hostname2.ppk

Either way, the file should have 600 permissions. Print the public key:

puttygen -L ~/.ssh/$hostname.ppk

Then for the user you want to log in as, copy the output to the user's .ssh/authorized_keys file. It also needs to have 600 permissions.

Converting Between the Two

Let's say you have a public key file in OpenSSH2's native format (like PuTTY generates). Here's how to create one:

puttygen -O public testkeyforwaypoint.ppk > testkey1a.pub

You can convert it like this:

ssh-keygen -i -f testkey1a.pub > testkey2.pub

However, the converted key will have the comment stripped. Otherwise, it should match the OpenSSH private key output of the original.