How to restore ssh_config file in /etc/ssh [duplicate]

Solution 1:

The file /etc/ssh/ssh_config is part of the package openssh-client. Therefore

sudo apt-get purge openssh-client
sudo apt-get install openssh-client

or

sudo apt-get install --reinstall openssh-client

Purging the package ssh makes no sense, it's only a meta-package for openssh-client and openssh-server and purging this package doesn't purge openssh-client and openssh-server.

Solution 2:

The file /etc/ssh_config is a configuration file, which has special handling in dpkg, so it is preserved across package upgrades. If the file is deleted, this, too, is preserved, so merely reinstalling the package will not fix the problem.

Your choices are, to either

  • completely remove the package including its configuration files, as A.B. suggested, but this will remove all custom configuration for the package, or
  • reinstall the package by hand using dpkg, giving it the --force-confnew option to overwrite configuration files.

The latter option has the advantage of keeping other customized configuration files, renamed with a suffix of .dpkg-old.

To do this, you need a copy of the package file,

apt-get --download-only --reinstall install openssh-client

will download it to /var/cache/apt/archives, and

dpkg --force-confnew -i /var/cache/apt/archives/openssh-client_...

will install it (replace the ... with the version downloaded).

Solution 3:

Try :

sudo dpkg-reconfigure openssh-server