LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Regenerating ssh files (https://www.linuxquestions.org/questions/linux-software-2/regenerating-ssh-files-4175416026/)

the_gripmaster 07-10-2012 10:42 PM

Regenerating ssh files
 
After cloning a VM, how do I regenerate the files in /etc/ssh because these files are supposed to be different for different hosts:

Code:

[root@centos5 ~]# cd /etc/ssh
[root@centos5 ssh]#
[root@centos5 ssh]# ls -1
moduli
ssh_config
sshd_config
ssh_host_dsa_key
ssh_host_dsa_key.pub
ssh_host_key
ssh_host_key.pub
ssh_host_rsa_key
ssh_host_rsa_key.pub

  • The ssh_host_* files can be recreated using ssh-keygen.
  • The ssh*_config files can stay the same.
  • How do I recreate the moduli?

the_gripmaster 07-10-2012 10:58 PM

I think I found it

Code:

ssh-keygen -G moduli.candidates -b 2048
ssh-keygen -T moduli -f moduli.candidates


the_gripmaster 07-11-2012 12:53 AM

It looks like moduli is the same set of groups on all CentOS servers. So it does not need to be regenerated. In case someone is looking for the same, here are the complete steps to recreate the private and public keys:

Code:

ssh-keygen -C '' -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -C '' -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -C '' -t rsa1 -f /etc/ssh/ssh_host_key


unSpawn 07-11-2012 12:58 AM

The /etc/init.d/sshd init script already checks for and will generate them OTF if these files are not available, so basically delete the keys and restart the service.


All times are GMT -5. The time now is 09:58 AM.