|
An essay before we talk about how to install a Linux deployment Wetty service, but we see, enter http://127.0.0.1:3000 in the browser when visiting, we also need to enter the account password for authentication.
However, in some scenarios, we do not need to enter the account password to authenticate the user, and the user does not necessarily know the account password. We want our users to directly open command operations.
Input node app.js command line terminal will be the following tips, which lists all of the options described start wetty services.
These options see wetty by ssh for operation of the terminal, which is used to specify which --sshauth ssh authentication mode, the default password, represented by account password authentication method.
Ssh There are four kinds of authentication: hostbased, publickey, keyboard-interactive, password. That is where we said above password account password authentication; publickey is the RSA public key authentication; we do not care about the other two.
Wetty default password authentication is used, we can publickey authentication can be specified by --sshauth option. About ssh public key authentication mechanism are:
Users will own public key stored on the remote host. Login time, remote host sends a random string to the user, with its private key encryption, and then sent back. Remote host using the public key to decrypt stored in advance and, if successful, would prove that the user is authentic, allow direct login shell, no longer requires a password.
Then we need to open a command line terminal, enter
$ Ssh-keygen
To generate our public and private key.
This command generates a default public and private keys are stored in ~ / .ssh directory,
Wherein id_rsa file is saved in the private key, id_rsa.pub file is saved in the public key.
The above ssh public key authentication mechanism we need to talk about the public key to the remote machine to save, save after the login user's home directory ~ / .ssh / authorized_keys file. The public key is a string, as long as it is added at the end of the authorized_keys file on the line. At a time when our remote machine is the local machine, so we only need to ~ / .ssh / id_rsa.pub copy and named authorized_keys can.
$ Cp ~ / .ssh / id_rsa.pub ~ / .ssh / authorized_keys
Then we switch to the wetty directory, start wetty service,
$ Node app.js -p 3000 --sshauth = publickey
Then enter http://127.0.0.1:3000/ in your browser, you can see at this time do not need to enter the account password can be directly manipulated
If we suspect every boot option to also specify --sshauth too much trouble, we can directly modify app.js file in the source code. Open app.js file, we can see that it is specified in line 45 sshauth default authentication mode is password, we only need to modify it to publickey can. |
|
|
|