web123456

Check the ssh port number_SSH usage detailed explanation

1. On machine A, execute the following command:

2. If it is the first time that the machine is connected to cetosB through ssh, it will prompt to confirm the public key and let you choose whether to confirm the connection.

3. Because the local network card address can be omitted, the above forwarding can be abbreviated as:

4. Now, what I need to operate is to log in to 192.168.13.135 through SSH.

5、centosB(192.168.13.142)

6. If you log in to the remote host for the first time on this machine, the following interface will appear.

7. At this time, if the following command is executed, it will be forwarded to port 80 of 127.0.0.1 of machine A, as follows:

8. You can see on machine B that our monitoring is as follows:

9、win7(10.18.78.135)

10. There is a port of the local network server and forward it to a port of the remote server. To put it bluntly, the request sent to the local port will be forwarded to the target port. The format is as follows:

11. For local forwarding and remote forwarding of SSH, both local ports and remote ports need to be bound one by one, and the format is as follows:

12、centosB(192.168.13.142)

13. So, now I start centosB (192.168.13.142) to restrict the non-allowing of external ip connections, and only let 127.0.0.1 connections, as follows:

14. First, the application on centosA (192.168.13.139) sends data to the local port 3306 above 127.0.0.1.

15. Then set dynamic forwarding again, as follows:

16. Of course, it is still accessible in centosB(192.168.13.142).

17. Then, on machine B, if you access the service of machine A, you want to access your own service.

18. On machine A, execute the following command:

19. At this time, we can use the local port to forward, map a local port to the centosB (192.168.13.142) machine, as follows:

20. Of course, if there are other machines, you can also use a similar method to request machine A.

21. At this time, we connect mysql on centosB to centosA and we can write it like this.

22. Local forwarding, to put it bluntly, is to forward a request sent to a local port to a remote machine. The format is as follows:

23. Use the following command to connect.

24、

25. We listened to port 8081 of machine B and forwarded the request from this port to machine A.

26. At this time, we still use the above mysql connection method, and there will definitely be an error, as follows:

27. The default port number is 22. When the port number is 22, it can be omitted and used directly as follows:

28. Syntax:

29. Now, we have started the Nginx service on the A machine, as follows:

30. user: the logged-in username.

31. Host: the logged-in host.

32. Then, centosB (192.168.13.142) returns the processed data to centosA (192.168.13.139).

33. As follows:

34. The following three machines are as examples, as follows:

35. You need to execute the following code on machine B:

36. You can see that at this time, machine B has already monitored 0:0.0.0:8081

37. Of course, we can also use the scp command or the rz command to transfer files.

38. Of course, when connecting ssh, if the usernames of the two machines are the same, it can also be omitted, that is, the command can be abbreviated as:

39、centosA(192.168.13.139)

40. Case 1. Check the operating system type of machine B (192.168.13.148) in machine A (192.168.13.149).

41. We can view the ssh forwarding and listening process in centosA through the following command.

42. -p: Specify the port number.

43. Now, mysql is installed on the centosB (192.168.13.142) machine and set up any host connection to run, as follows:

44. At this time, how to connect mysql to centosB (192.168.13.139) on centosA (192.168.13.142)?

45. Remote forwarding means forwarding a port request sent to the remote machine to the local machine. The format is as follows:

46. ​​If you want to exit, just enter exit.

47. The data flow is as shown in the figure:

48. Case 1. Access the service of machine A (192.168.13.148) on machine B (192.168.13.149).

49. Now we use local forwarding to solve a problem, for example, we have two machines, as follows:

50. Case 3. Check whether machine B (192.168.13.149) monitors port 1080 at machine A (192.168.13.148).

51. Then enter the password and you can connect to OK.

52. Case 2. Copy the test folder in machine A (192.168.13.148) to machine B (192.168.13.149).

53. Parameters:

54. Ssh-R remote network card address: Remote port: Destination address: Destination port

55. SSH remote operation is mainly used to perform an operation on a remote machine. The format is as follows:

56. Article from: 360 Cloud Computing

57. It is forwarded from a port of the remote server to a port of the server on the local network. To put it bluntly, it means forwarding the request sent to the remote port to the target port. The format is as follows:

58、centosA(192.168.13.139)

59. For example, forward all the requests sent to machine B to machine A, and let machine A execute the request.

60. In the above case, we can also achieve it through remote forwarding. That is, execute the following code on machine A:

61. Ssh-L local network card address: local port: target address: target port user@ target address.

62. Execute the following code on machine A:

63. In addition, if the user name being used locally is the same as the user name for remote login, the login user name can also be omitted, that is, as follows:

64. The general meaning is that you cannot confirm the authenticity of the host host. You only know its public key fingerprint. Do you still want to continue connecting? Just enter yes.

65. First of all, we can use the following command to check whether ssh is enabled on both machines.

66. On machine C, we simulate requests through curl and use machine B as a proxy, as follows: