Upgrading the pit of OpenSSH

Reinstall openssh with compilation (success):

1. First delete the original package with yum remove openssh-server, and download the higher version from the openssh official website: http://www.openssh.com/openbsd.html (I use openssh-7.3p1.tar.gz, which is available in The official website was not found, so I downloaded the package on csdn)
2. Compile and install: tar -xvzf openssh-7.3p1.tar.gz -C /opt && cd /opt/openssh-7.3p1
./configure && ; make && make install [ ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-tcp-wrappers --with-ssl -dir=/usr/local/ssl --without-hardening] (not configured with parameters)
3. Copy the ssh service file: cp ./contrib/redhat/sshd.init /etc/init.d/sshd
chmod + x /etc/init.d/sshd
4. Modify the SSHD service file:
vim /etc/init.d/sshd
Modify the following content
SSHD=/usr/sbin/sshd is SSHD=/usr/local/sbin/sshd [Line 25 ]
/usr/sbin/ssh-keygen -A is /usr/local/bin/ssh-keygen -A [Line 41]
Save and exit
5. Add system service:
chkconfig --add sshd
to check whether the system startup service has been added to change the item
  chkconfig --list |grep sshd
  sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6. Allow root user to log in remotely:
cp sshd_config /etc/ssh/sshd_config
vim /etc/ssh/sshd_config Modify PermitRootLogin yes, and remove the comment
7. Configure to allow root user to log in remotely:
This operation is very important! Very important! Very important! The important thing is said three times, because openssh is installed, the sshd_config file is not executed by default, so even if the sshd_config is configured to allow the root user to log in remotely, it will not take effect without this command!
vim /etc/init.d/sshd
add a line above the line '$SSHD $OPTIONS && success || failure' [Line 51]:
OPTIONS="-f /etc/ssh/sshd_config"
save and exit
execution : service sshd start, green OK appears,
execute: service sshd status, the following error message appears at this time:
error: sshd dead but subsys locked
Solution:
rm -rf /dev/null
mknod /dev/null c 1 3
After starting again, sshd is running, ports and processes appear:
service sshd start
service sshd status
     sshd is running......
ports and processes All appeared:
ps aux|grep ssh
netstat -atnlp|grep ssh got it
.
Summary: The cause of the failure is unknown. The ssh service installed in yum mode failed to start successfully. It may be that some processes associated with SSH need to restart the system to take effect (the production environment does not allow to restart the system at will). The ssh installed by compilation is not associated with the previous process, so it can be started successfully.
As for why the ssh service fails, it is currently impossible to find out the reason. When compiling openssh, you can add parameters (--with-pam, --with-tcp-wrappers, etc.) as needed.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326046508&siteId=291194637