1

In the /etc/ssh directory exists the following content:

moduli      sshd_config           ssh_host_ecdsa_key      ssh_host_ed25519_key      ssh_host_rsa_key      ssh_import_id
ssh_config  sshd_config.ucf-dist  ssh_host_ecdsa_key.pub  ssh_host_ed25519_key.pub  ssh_host_rsa_key.pub

I can see practically two categories:

  1. public/private keys
  2. configuration files

If any of those files for any of these categories is deleted by mistake.

How that file can be re-generated? Is possible?, How? it according of each category (1 or 2)

pa4080
  • 30,621

1 Answers1

3

In Ubuntu the OpenSSH client/server configuration files are:

  • /etc/ssh/sshd_config - the configuration file of the SSH server (daemon). Additional configuration files could be added in the directory /etc/ssh/sshd_config.d/ and their file extensions must be .conf (these are invoked in the beginning of /etc/ssh/sshd_config).

  • /etc/ssh/ssh_config - system wide configuration file for the SSH client, the settings in this file are applied to all users. Additional configuration files could be added in the directory /etc/ssh/ssh_config.d/ and their file extensions must be .conf (these are invoked in the beginning of /etc/ssh/ssh_config).

  • ~/.ssh/config - a personal configuration file for the SSH client. This file is located in the user's home directory within a special directory named .ssh. The directory itself must have private permissions (700), and the files inside also must be private (600).

The public/private keys are possession of a user, thus they are private :) By default they are located in user's directory ~/.ssh.

In this answer of mine in sections 1 and 2 is described how to setup key based SSH authentication: https://askubuntu.com/a/986245/566421

Here is an example of a case in which the SSH keys are not located in the user's home directory: https://askubuntu.com/a/882379/566421

If you want to recreate the directory /etc/ssh you could purge the OpenSSH client and server then reinstall them (but you may not need this):

sudo apt update
sudo apt purge openssh-client openssh-server
sudo rm -R /etc/ssh
sudo apt install openssh-client openssh-server
pa4080
  • 30,621