Linux SSH command instance Guide
If you have been in the IT circle for a long time, you should have heard about SSH, a great tool and its security features. this tutorial allows you to quickly learn how to securely and conveniently connect to a remote computer through SSH.
If you have no idea about SSH, visit Wikipedia first.
How to Improve the SSH login authentication speed of Ubuntu
Enable the SSH service to allow Android phones to remotely access Ubuntu 14.04
How to add dual authentication for SSH in Linux
Configure the SFTP environment for non-SSH users in Linux
Configure and manage the SSH service on Linux
Basic SSH tutorial
Basic usage
You only need to specify the username and host name parameters for the simplest SSH command. The host name can be an IP address or domain name. The command format is as follows:
- $ Ssh user @ hostname
For example, to log on to a Raspberry Pi system in my LAN, simply enter the following command in the command line:
- $ Ssh pi@10.42.0.47.
In the command, pi and 10.42.0.47 are the usernames and lan ip addresses of my Raspberry pi system. In actual use, the host name must be changed to the IP address of your target host (LAN or remote.
If you can log on successfully, the following content is easy for you.
Use other ports
SSH is connected to port 22 of the target host by default, but you may need to connect to other ports for various reasons.
- $ Ssh-p 10022 user @ hostname
The above command is to add the parameter-p to specify the port number as 10022.
Remote Command Execution
Sometimes it is convenient to execute a command on the remote host and display it locally, and then continue working locally. SSH can meet this requirement:
- $ Ssh pi@10.42.0.47 ls-l
For example, the above command will enumerate the content of the remote host's main directory and display it locally. Isn't it cool? You can try other commands.
Mount a Remote File System
Another great SSH-based tool, sshfs. sshfs, allows you to directly mount the file system of the remote host locally.
- $ Sshfs-o idmap = user @ hostname:/home/user ~ /Remote
For example, the following command:
- $ Sshfs-o idmap = user pi@10.42.0.47:/home/pi ~ /Pi
This command mounts the Home Directory of the remote host pi user to the Pi folder under the local home directory.
For more information, see the sshfs tutorial.
X11 graphic interface
If you want to run a graphic interface program on the remote host, SSH will help you think of it! You can use the SSH basic command and the parameter-X to connect to the remote host to enable the X11 forwarding function. after logging on, you may feel that there is no difference, but when you run a graphic interface program, you will find that there are different.
- $ Ssh-X pi@10.42.0.47
-
- $ Pistore
If you want to do something else while running the graphic interface program, simply add an & symbol at the end of the command.
- $ Pistore &
For more details, please continue to read the highlights on the next page: