Thursday, October 16, 2008

How I recreated my system's (deleted) SSH keys?

I goofed up my solaris server unintentionally by deleting all SSH keys and then rebooted. Result.. I was not able to remote login to this server with ssh. Here is the process how I recreated my system's SSH Keys from scratch:



After key deletion, my /etc/ssh directory looked like below:

-bash-3.00# ls -l /etc/ssh
total 200
-rw-r--r-- 1 root sys 88301 Jan 22 2005 moduli
-rw-r--r-- 1 root sys 861 Jan 22 2005 ssh_config
-rw-r--r-- 1 root sys 5204 Apr 30 12:08 sshd_config


-bash-3.00# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa): /etc/ssh/ssh_host_rsa_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.
The key fingerprint is:
ba:c4:63:4b:34:0b:bc:2a:5d:7b:5e:ae:7f:5a:3a:eb root@server01

-bash-3.00# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (//.ssh/id_dsa): /etc/ssh/ssh_host_dsa_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /etc/ssh/ssh_host_dsa_key.
Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.
The key fingerprint is:
5c:8f:8b:22:2c:6a:ab:ce:c8:40:75:58:ed:8b:20:f8 root@server01

-bash-3.00# ssh-keygen -t rsa1
Generating public/private rsa1 key pair.
Enter file in which to save the key (//.ssh/identity): /etc/ssh/ssh_host_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /etc/ssh/ssh_host_key.
Your public key has been saved in /etc/ssh/ssh_host_key.pub.
The key fingerprint is:
a0:9d:38:eb:44:23:9f:40:b5:62:fe:30:69:dc:75:2b root@server01

-bash-3.00# svcs -a | grep -i ssh
maintenance 9:25:17 svc:/network/ssh:default

-bash-3.00# svcadm clear /network/ssh

-bash-3.00# svcs -a | grep -i ssh
online 10:02:29 svc:/network/ssh:default

-bash-3.00# ls -l /etc/ssh
total 200
-rw-r--r-- 1 root sys 88301 Jan 22 2005 moduli
-rw-r--r-- 1 root sys 861 Jan 22 2005 ssh_config
-rw-r--r-- 1 root sys 5204 Apr 30 12:08 sshd_config
-rw------- 1 root root 668 Oct 16 09:54 ssh_host_dsa_key
-rw-r--r-- 1 root root 604 Oct 16 09:54 ssh_host_dsa_key.pub
-rw------- 1 root root 529 Oct 16 09:54 ssh_host_key
-rw-r--r-- 1 root root 333 Oct 16 09:54 ssh_host_key.pub
-rw------- 1 root root 887 Oct 16 09:54 ssh_host_rsa_key
-rw-r--r-- 1 root root 224 Oct 16 09:54 ssh_host_rsa_key.pub

-bash-3.00#

No comments: