Linux settings Wetty do not need to log on to command line operation

Source: Internet
Author: User
Tags openssl ssh ssh access git clone

Wetty installation and usage instructions under Linux system

1. Wetty Introduction

Wetty is an open-source web-based SSH developed using Node.js and WebSockets. For more information on web-based SSH please refer to Https://en.wikipedia.org/wiki/Web-based_SSH.

and Wetty information please refer to Https://github.com/krishnasrinivas/wetty.


2. Environmental preparedness

Because the Wetty is written using node.js, we have to install the relevant node.js environment beforehand.


3. Wetty Installation

Run the following command to install the

$ git clone https://github.com/krishnasrinivas/wetty
$ CD Wetty
$ sudo npm install

The installation process may be wrong, please refer to the following possible problem handling.


4. Verify

After the installation is complete, then run the following command to start the Wetty service and listen for the 3000 port number.

$ node App.js-p 3000



Then open the browser, enter the http://127.0.0.1:3000, and then enter the password to login successfully after the command line operation, the effect shown in the following figure,


5. Possible problem-handling


5.1 Installation times error: ' Use ' isn't ' a ' node::buffer '

Because the node I installed is version 4.1.1, it's too new. And Wetty originally rely on the pty.js too old, lead to compile problems. Modify the Package.json in the following Wetty source code directory to modify the dependent pty.js to the latest version 0.3.0 (originally ^0.2.7-1). Save the file, and then rerun the sudo npm install command.


5.2 SSH Access failed

After starting the Wetty service, enter the http://127.0.0.1:3000 times in the browser a "ssh:connect to host localhost port 22:connection refused" error similar to the screenshot below.

Run the following command to reinstall Openssl-client and Openssl-server,

$ sudo apt-get remove openssh-client openssh-server
$ sudo apt-get installopenssh-client openssh-server


Set wetty command-line operation without the need for an account login

Above we learned how Linux installs the deployment Wetty service, but we see, in the browser input http://127.0.0.1:3000 for access, we also need to enter the account password for authentication (as shown in the first line of the figure).



But in some scenarios, we do not need user input account password for authentication, and users do not necessarily know the account password. We want the user to open the command operation directly.

Entering node app.js in a command line terminal prompts you with a list of all the options for starting the Wetty service.


From these options in the above, see Wetty is through SSH for terminal operation, and the--sshauth is used to specify SSH authentication mode, its default is password, means authentication through account password. For SSH and SSH authentication mode we can refer to the following several documents.

(1) Nanyi's blog: SSH principle and application (i): remote login;

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

(3) Linux/unix Command:ssh

(4) Linux/unix Command:ssh_config

SSH authentication method has four kinds: hostbased, publickey, keyboard-interactive, password. Among them password that we said above account password Authentication way; PublicKey is RSA public key authentication way; The other two we don't care for the moment.

Wetty default is the password authentication method, we can specify the--sshauth option for PublicKey authentication. The authentication mechanism for the SSH public key is:

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

So we need to open a command-line terminal first and then enter

$ ssh-keygen

To generate our public and private keys.


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


The private key is saved in the Id_rsa file and the public key is saved in the Id_rsa.pub file.

Above SSH public key authentication mechanism provides we need to speak the public key to save to the remote machine, save in the ~/.ssh/authorized_keys file of the user's home directory after the 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 have to copy the ~/.ssh/id_rsa.pub and name it Authorized_keys.

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


Then we switch to the Wetty directory and start the Wetty service,

$ node App.js-p 3000--sshauth=publickey


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



If we think that every time we start to specify the--sshauth option too cumbersome, we can directly modify the App.js file source code. To open the App.js file, we can see that the default authentication method of Sshauth specified in line 45th is password, we just need to modify it to PublicKey.

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.