Skip to main content
Version: 3.x

Host Management

Introduction

Manage and maintain the hosts that the platform can operate. When adding a host for the first time, you need to enter the password of the specified user of ssh.

Principle Description

Spug will try to connect to the target host directly through the key when adding a host for the first time, and there will be the following 3 possibilities:

  1. If the target host does not support key authentication, an exception (error code E01) will be thrown directly and the request will be terminated.
  2. If the key authentication is successful, the host is added directly and the process is completed.
  3. If the key authentication fails, a password input box will pop up, and the user will enter the password and set the key authentication (if the target host does not support password authentication, an exception (error code E00) will be thrown directly and the request will be terminated).

In the third case, the user enters the password, and Spug tries to connect to the target host through the password after receiving the password and execute the following command to set the key authentication

mkdir -p -m 700 ~/.ssh
echo 'public key content ....' >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

After the above operation, Spug will try to connect to the target host using the key again, and there will be the following 2 possibilities:

  1. Authentication fails, an exception (error code E02) is thrown directly and the request is terminated.
  2. Authentication succeeds, the complete host is added.

Error Description

  • E00 Indicates that the target host does not support password authentication. You can usually try to view the sshd configuration file /etc/ssh/sshd_config of the target host to ensure that PasswordAuthentication yes.
  • E01 Indicates that the target host does not support key authentication. You can usually try to view the sshd configuration file /etc/ssh/sshd_config of the target host to ensure that PubkeyAuthentication yes.

  • E02 After Spug tries to set the key authentication, it still cannot connect to the host normally through the key. You can try the following checks.

    • User home directory such as /root directory permissions are 700
    • ~/.ssh directory permissions are 700, file permissions 600
    • The owner and group of the above files are the current user
    • Check the SSH system log, for example Centos is located at /var/log/secure
    • If you can manually operate to achieve key authentication, you can try to achieve key authentication yourself, and then add the host again after the test is passed
    • If the above are all checked and it still doesn't work, feel free to feedback to us