Linux Generate RSA SSH Keys

Using the ssh-keygen command (open terminal/konsole and type):

~# ssh-keygen -t rsa

OR

~# ssh-keygen

Sample:
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory ‘/home/user/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
78:3b:83:f5:df:18:d0:af:4g:90:08:c5:4c:02:50:f2 user@debian

The -t (type) option specifies the type of key to create. It can be “rsa” or “dsa” for protocol v2. The $HOME/.ssh stores the following:

$HOME/.ssh/id_rsa – Which is your private key
$HOME/.ssh/id_rsa.pub – Which is your public key

It’s best not to share key files with anyone else. But you can upload keys to a remote server using:

~# ssh-copy-id username@server1.example.co.uk

You can now log in to the remote server using:

~# ssh username@server1.example.co.uk

Disable the password for root login (Be careful)

Open up the SSH config file using an editor of your choosing:

~# nano /etc/ssh/sshd_config

In this file find the line that has PermitRootLogin and modify this:

PermitRootLogin without-password

To make the changes:

reload ssh & done.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s