Centos7.6 system upgrade openssh

1.Upgrade

First, I need to emphasize that although I will provide basic upgrade steps, you need to make sure you have created a backup of all important data and configuration before proceeding. Any errors during the upgrade may result in data loss. This is what you need to be prepared for.

Next, we can follow these steps:

1. **Preparation**: First, you need to obtain root permissions, because root permissions are required to install and upgrade system software. Enter the following command at the command line:
    ```
    su
    ```
    Or if you are on a system that supports sudo, you can use:
    ```
    sudo su
    ```
    Enter your password to gain root privileges.

2. **Back up the current version**: Before starting the upgrade, it is best to back up your current SSH configuration file. Enter the following command:
    ```
    cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
    ```

3. **Unzip the installation package**: First enter the directory where you saved the installation package, and then use the following command to decompress the compressed file: ```
    tar
    zxvf openssh-9.3p2.tar.gz
    ```
4. **Compile and install **: Enter the decompressed directory and compile and install:
    ```
    cd openssh-9.3p2
    ./configure --prefix=/usr --sysconfdir=/etc/ssh
    make && make install
    ```
   These commands will configure , compile and install the new version of OpenSSH.

5. **Check Version**: After the installation is complete, you should check whether the new version has been successfully installed. You can check the version using the following command:
    ```
    ssh -V
    ```
    This will display your currently installed version of OpenSSH.

6. **Restart SSH service**: Finally, restart your SSH service to make the new configuration take effect: ```
    service
    sshd restart
    ```

Again, before performing any system upgrade, make sure you have backed up all important data and configurations. If you encounter any problems during the upgrade process, you can go back to your backup and seek professional help.

Roll back if there is a problem with the upgrade:

If you backed up `sshd_config` and `ssh_config` before upgrading OpenSSH, and you now need to roll back to an older version, you can follow these steps:

1. **Stop SSH service**: You should stop the SSH service first to prevent interference with running services during the rollback process. You can stop the SSH service using the following command:
    ```
    service sshd stop
    ```

2. **Restore configuration file**: Use the `cp` command to copy the backed-up configuration file back to its original location. For example:
    ```
    cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
    cp /etc/ssh/ssh_config.bak /etc/ssh/ssh_config
    ```

3. **Uninstall the new version**: The specific operation of this step depends on how you installed the new version. If you installed via a package manager, you should use the same package manager to uninstall. If you installed from source, you may need to manually remove the files for the new version. You can also check whether your OpenSSH source package provides the `make uninstall` command to automatically uninstall.

4. **Reinstall the old version**: You may need to reinstall the old version of OpenSSH, depending on whether you also uninstalled the old version when you uninstalled the new version. You can reinstall it the same way you installed the old version before.

5. **Restart SSH service**: Finally, restart your SSH service to make the old configuration take effect: ```
    service
    sshd start
    ```

Rollback can be a complex process, and if you encounter any problems during the process, you should seek professional help. After you complete the rollback and restart the SSH service, you should test as soon as possible to confirm that the SSH service is working properly.

Guess you like

Origin blog.csdn.net/u013933709/article/details/131923001