| #!/bin/bash |
| |
| check() { |
| if [ "$?" != "0" ] |
| then |
| echo -e "\e[31m Install OpenSSH Failed!!! \e[0m" |
| exit 6 |
| fi |
| } |
| |
| echo -e "\033[32m Begain Installing. \033[0m" |
| tar -zxf openssh-10.0p1.tar.gz |
| tar -zxf openssl-3.3.1.tar.gz |
| tar -zxf zlib-1.3.1.tar.gz |
| |
| cd zlib-1.3.1/ |
| ./configure --prefix=/usr/local/zlib |
| check |
| |
| make && make install |
| check |
| |
| cd ../openssl-3.3.1/ |
| ./configure --prefix=/usr/local/openssl |
| check |
| |
| make -j 4 && make install |
| check |
| |
| echo "/usr/local/openssl/lib" >> /etc/ld.so.conf |
| ldconfig |
| ldconfig -p | grep ssl |
| echo "export PATH=/usr/local/openssl/bin:$PATH" >> /etc/profile |
| source /etc/profile |
| check |
| |
| mv /etc/ssh /etc/ssh_bak |
| mv /usr/bin/ssh /usr/bin/ssh_bak |
| mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen_bak |
| mv /usr/sbin/sshd /usr/sbin/sshd_bak |
| cp -a /etc/pam.d/sshd /etc/pam.d/sshd_bak |
| |
| cd ../openssh-10.0p1/ |
| ./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib |
| check |
| |
| make && make install |
| check |
| |
| cp -a /usr/local/openssh/sbin/sshd /usr/sbin/sshd |
| cp -a /usr/local/openssh/bin/ssh /usr/bin/ssh |
| cp -a /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen |
| cp -a /root/openssh/openssh-10.0p1/contrib/redhat/sshd.init /etc/init.d/sshd |
| chmod +x /etc/init.d/sshd |
| |
| echo "PermitRootLogin yes" >> /etc/ssh/sshd_config |
| echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config |
| echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config |
| |
| cat > /etc/systemd/system/sshd.service << 'EOF' |
| [Unit] |
| Description=OpenSSH Server |
| After=network.target |
| |
| [Service] |
| ExecStart=/usr/local/openssh/sbin/sshd -f /etc/ssh/sshd_config |
| Restart=on-failure |
| |
| [Install] |
| WantedBy=multi-user.target |
| EOF |
| |
| chmod +x /etc/systemd/system/sshd.service |
| |
| systemctl daemon-reload |
| systemctl enable sshd |
| systemctl restart sshd |
| |
| echo -e "\033[32m The new OpenSSH Version: \033[0m" |
| sshd -V |