In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the usage of SSH command under Linux, which can be used for reference. Friends who need it can refer to it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
A system administrator may manage multiple servers at the same time, and these servers may be placed in different places. It is obviously not the best way to manage them by visiting them in person, and the method of remote control should be the most effective.
There are probably several remote management tools of Linux system: telnet,ssh,vnc and so on, among which ssh is the most commonly used management method, which adopts ciphertext transmission mode, which is simple and secure.
The abbreviation of Secure Shell is SSH, which is formulated by IETF's Network working Group (Network Working Group). SSH is a security protocol created on the basis of application layer and transport layer, which provides a secure transmission and use environment for computer shell.
Let's introduce the seven uses of SSH.
1. Basic usage
The simplest use is to enter ssh with no parameters and add the host address, such as:
Ssh 192.168.0.116
If you log in to the host in this way, you will log in using the current user by default. When connecting for the first time, SSH will confirm the authenticity of the target host, and if there is no problem, type yes.
If we want to log in to the host with the specified user name, there are two ways:
a. Use the-l option
Ssh-l alvin 192.168.0.116
b. Use user@hostname format
Ssh alvin@192.168.0.116
Of these two methods, the second is particularly commonly used.
two。 Specify port login
The default port number used by SSH is 22. Most modern Linux systems have port 22 open. If you run the ssh program without specifying a port number, it sends the request directly through port 22.
If we do not want to log in through port 22, we can use the-p option to specify the port.
Ssh 192.168.0.116-p 1234
Extended topic: how to change the port number?
Just modify / etc/ssh/ssh_config by modifying the following line:
Port 223. Request compression for all data
Using the-C option, all data sent or received through SSH will be compressed and still encrypted.
Ssh-C 192.168.0.116
However, this option is useful when the network speed is not very fast, and when the network speed is fast, using compression will reduce efficiency, so use it on a case-by-case basis.
4. Turn on debug mode
For some reason, we want to track and debug the SSH connections we have established. The-v option parameter provided by SSH is set for this purpose. It can see where something went wrong.
[Alvin.Alvin-computer] ➤ ssh-v pi@192.168.0.116OpenSSH_7.1p2, OpenSSL 1.0.1g 7 Apr 2014debug1: Reading configuration data / etc/ssh_configdebug1: Connecting to 192.168.0.116 [192.168.0.116] port 22.debug1: Connection established.debug1: key_load_public: No such file or directorydebug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_7.1debug1: Remote protocol version 2.0 Remote software version OpenSSH_7.4p1 Raspbian-10+deb9u4debug1: match: OpenSSH_7.4p1 Raspbian-10+deb9u4 pat OpenSSH* compat 0x04000000debug1: Authenticating to 192.168.0.116 as' pi'debug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT received5. Bind source address
If your client has more than two IP addresses, you can't tell which IP to use to connect to the SSH server. To resolve this situation, we can use the-b option to specify an IP address. This IP will be used as the source address to establish the connection.
[Alvin.Alvin-computer] ➤ ssh-b 192.168.0.105 pi@192.168.0.116Linux raspberrypi 4.14.71 ssh v7 + # 1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7lThe programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described in theindividual files in / usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.Last login: Sun Feb 24 08:52:29 2019 from 192.168.0.1056. Execute command remotely
If we want to execute a command on the target host, our usual practice is to log in to the target host, execute the command, and then exit. Of course it's OK to do so, but it's troublesome.
If we just want to execute a command remotely, we can just follow the command directly, as follows:
➤ ssh pi@192.168.0.116 ls-lDesktopDocumentsDownloadsMagPiMusic7. Mount a remote file system
Another great SSH-based tool is called sshfs. Sshfs allows you to mount the file system of a remote host directly locally. It is used in the following format:
Sshfs-o idmap=user user@hostname:/home/user ~ / Remote
For example:
Sshfs-o idmap=user pi@192.168.0.116:/home/pi ~ / Pi Thank you for reading this article carefully. I hope the editor will share what is helpful to you in the usage of the SSH command under Linux. At the same time, I also hope that you will support it, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.