Summary of common SSH usage

Source: Internet
Author: User
Common usage of SSH 1. connect to a remote host: Command Format: SSH [email protected] or SSH remoteserver-l Name Description: both methods can remotely log on to the remote host, the server represents the remote host, and the name is the username used to log on to the remote host. 2. Connect to the port specified by the remote host. Command Format: SSH [email protected]-P 2222 or SSH remoteserver-l name-P 2222. Description: The p parameter specifies the port number, generally, when port ing is performed in a route, we do not directly map port 22, but convert it to another port number. In this case, we need to use the-P port number command format. 3. Jump to remote host 2 through remote host 1: Command Format: SSH-T remoteserver1 SSH remoteserver2 Description: When remote host remoteserver2 cannot be directly delivered, you can use the-t parameter, then, remoteserver1 redirects to remoteserver2. In this process, you must first enter the password of remoteserver1, then enter the password of remoteserver2, and then you can operate remoteserver2. 4. Run the remote shell command via SSH: Command Format: SSH-l name remoteserver 'command' Description: connect to the remote host and execute the command of the remote host. For example, view the memory usage of the remote host. $ Ssh-l root 192.168.1.100 svmon-G5, modify the SSH listening port: by default, ssh listens to connection port 22. Attackers can use the port scanning software to check whether the host runs the SSH service, it is wise to change the ssh port to a port greater than 1024, because most port scanning software (including NMAP) does not scan the high port by default. Open the/etc/ssh/sshd_config file and find the following line: port 22, remove the # sign before the line, modify the port number, and restart the SSH service: $/etc/init. d/ssh restart6. Only SSH protocol version 2 is allowed: There are two SSH protocol versions. Only SSH protocol version 2 is more secure. SSH protocol version 1 has security issues, man-in-the-middle and insertion attacks are included. Edit the/etc/ssh/sshd_config file and find the following line: # modify protocol to Protocol 27 and disable root user logon. Generally, the root user is not directly used to log on to the remote host. Because the root user has super permissions, this poses a security risk. Therefore, when you need to manage the remote host, switch to the root user. Open the/etc/ssh/sshd_config file and find the following line: # permitrootlogin Yes remove #, then modify yes to no, and restart the SSH service, this prevents the root user from logging on. 8. When the parameter is set, the system prompts you to edit a file first, for example, bannertest.txt. The file content is customized. Open the/etc/ssh/sshd_config file and find the following line: # Banner/Some/pathreplace the full path of the bannertest.txt file with/Some/path, save the file, and restart the SSH service. When the client crashes, it will see the prompt information in the bannertest.txt file. 9. Port ing: if the company's Intranet has a Web server, but only internal and external, the Internet will not be accessible, you can use SSH to perform port ing to access the Intranet web server over the Internet. Assume that the Web server is named webserver. webserver can access remoteserver on the remote host through SSH, log on to Webserver, and run the following command to map the Command Format: SSH-r 3000: localhost: after the 80 remoteserver is executed, run netstat-an | grep 3000 on the remoteserver to check whether port 3000 is enabled. Run the following command to check whether the web page $ w3m http: // 127.0.0.1: 3000 on WebServer is successfully mapped. however, this is only limited to local access to the Web server, that is, only the remoteserver machine can access webserver. Port 3000 is bound to port 127.0.0.1 of the remoteserver. You can edit the/etc/ssh/sshd_config file on the remoteserver and add the following content: Add gatewayports yes and bind the listening port 3000 to the 0.0.0.0 address, in this way, all external machines can access the listening port and save and exit. And restart the SSH service. After completion, other machines can enter http: // remoteserver: 3000 in the browser to access webserver. Http://www.aixchina.net/home/space.php? Uid = 73104 & Do = Blog & id = 30463

Summary of common SSH usage

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.