Set Wetty do not require account login to perform command line operations

Source: Internet
Author: User

Previous essay we will install Linux How to deploy the Wetty service, but we see that in the browser input http://127.0.0.1:3000 when visiting, we also need to enter the account password for authentication (as shown in the first line).

However, in some scenarios, we do not need the user to enter the account password for authentication, and users do not necessarily know the account password. We want the user to open it for direct command operation.

Entering node app.js in the command-line terminal will prompt you to list All the option descriptions for starting the Wetty service.

From these options, you see that Wetty is terminal operation via ssh , where --sshauth is used to specify ssh Authentication mode, which is passwordBy default, indicates the authentication through the account password method. We can refer to the following documents for the authentication mode of SSH and SSH.

(1) Nanyi's blog:SSH Principle and Application (a): remote login ;

(2)Https://en.wikipedia.org/wiki/Secure_Shell

(3)Linux/unix command:ssh

(4)Linux/unix command:ssh_config

There are four types of Ssh authentication methods:hostbased, PublicKey, keyboard-interactive, password. Which password that we said above the account password authentication method;PublicKey is the RSA Public key authentication method; The other two we don't care for a while.

Wetty by Default is the password authentication method, which we can specify by --sshauth option as PublicKey authentication method can be. the authentication mechanism for SSH public key is:

The user stores his or her public key on the remote host. When logged in, the remote host sends a random string to the user, which is encrypted with his or her private key and then sent back. The remote host decrypts with a pre-stored public key and, if successful, proves that the user is trustworthy, allowing the login shell to be logged in and no longer requiring a password.

Then we need to open a command-line terminal and enter

Ssh-keygen

To generate our public and private keys.

The public key and key generated by the command are saved by default in the ~/.ssh directory.

Where the private key is savedin the id_rsa file, the public key is saved in the Id_rsa.pub file.

The above ssh Public key authentication mechanism provides that we need to tell the public key to be saved to the remote machine and saved in the ~/.ssh/authorized_keys file of the user's home directory after login . The public key is a string, just append it to the end of the Authorized_keys file. at this point our remote machine is the local machine, so we just need to copy the ~/.ssh/id_rsa.pub and named Authorized_keys .

CP ~/. ssh/id_rsa.pub ~/. ssh/authorized_keys

Then we switch to the wetty directory and start the wetty Service,

 --sshauth=publickey

Then enter http://127.0.0.1:3000/in the browser, you can see that at this time do not need to enter the account password to directly operate, as shown in,

We can modify the source code in the app.js file directly if we are too bothered to specify the --sshauth option every time we start . Opening the app.js file, we can see that the default authentication method for the Sshauth specified in the first line is Password, we just need to change it to publickey .

(done)

Set Wetty do not require account login to perform command line operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.