summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-07-17 19:43:11 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-07-17 19:43:11 +0000
commit746b5ee2e2eb941d39bba1f8f78498e8fcb518cb (patch)
treee303cdb06ed6ec9dd049db1da7beba8ce131fb4a /etc
parent850b71ec84084c60dbfcbea8f2d1668486eabf28 (diff)
downloadpfsense-746b5ee2e2eb941d39bba1f8f78498e8fcb518cb.zip
pfsense-746b5ee2e2eb941d39bba1f8f78498e8fcb518cb.tar.gz
If any of the /etc/ssh/ files are corrupted then remove them so they will be forced to regenerate.
Diffstat (limited to 'etc')
-rwxr-xr-xetc/sshd17
1 files changed, 17 insertions, 0 deletions
diff --git a/etc/sshd b/etc/sshd
index b2ecf6e..af3e9e4 100755
--- a/etc/sshd
+++ b/etc/sshd
@@ -32,6 +32,23 @@
$stderr = fopen("php://stderr", "w");
+ function file_size($file) {
+ $size = filesize($file);
+ if ( $size == 0)
+ $size = exec("ls -l $file | awk '{print $5}'");
+ return $size;
+ }
+
+ /* if any of these files are 0 bytes then they are corrupted.
+ * remove them
+ */
+ $files_to_check = array('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');
+ foreach($files_to_check as $f2c) {
+ if(file_size($f2c)==0) {
+ mwexec("rm /etc/ssh_host*");
+ }
+ }
+
if($argv[1] == "stop" || $argv[0] == "stop") {
if(file_exists("/root/.authorized_keys")) {
$ak = return_filename_as_string("/root/.authorized_keys");
OpenPOWER on IntegriCloud