The Versatile SSH Utility On The LINUX CLI - Post #29
Better be getting serious man, we have lots of things to accomplish……...
A LINUX UTILITY TO MAXIMIZE EASE AND PRODUCTIVITY
It may be best if you have read my previous post regarding opening and closing programs using the linux cli, link below.
This post will not be focused yet on the advanced features of SSH, there will be another post for such as it entails much deeper discussions. Also, SSH is not on Windows for a long time, until Windows 10, so SSH is really gaining much adoption.
When desktops and servers are deployed, a way to move files and users around is always the first challenge that users and admins alike need to solve. There are many ways to go about this, but no other better and more secure way than thru SSH (Secure SHell).
Need to get some files from another PC over the network? Need to be at another server to check on something as the admin? Needing to transfer some files to another PC? Even monitoring and doing something on another PC while sitting at your desktop is a breeze with this utility. All communications over the network is even encrypted in the most secure manner.
SSH SPECIFIC EXAMPLES
-1. Get a file from another PC/Server and place it on your Linux Mint desktop:
*To get a file from a remote computer and place it at the local folder, type at the linux cli:
“scp [email protected]:/home/remoteuser/file1.txt /home/localuser”
*The above command uses copy over ssh (“scp”) of a file named “file1.txt” at the remote desktop with an IP address of “1.1.1.1” using the credentials of the user “user”, the said file will be saved in the local folder “/home/localuser”
*Be aware that the IP address 1.1.1.1 can be anywhere, including a desktop or server that is located in the US while you are sitting down at your PC in the Philippines.
--
-2. Move over to a different computer’s cli to acquire its own cli:
*To go to another computer’s cli, type at the local linux cli:
“ssh [email protected]”
*The above command is you wanting to go over to a different computer with an IP address “1.1.1.1” using the credential of the user “user”; this command will prompt you of the password of the remote computer’s user “user”, after you type the correct password you are now as if sitting down on that computer and opening up its linux cli
*There are lots of very good reasons as to why you want to be at the remote computer’s cli, and one of which is to at least see what files are on it before even copying it over the network using scp as per item #1
--
-3. Execute an important command on another computer while sitting down on your own desktop:
*To execute a command on a remote computer from your desktop, type at the linux cli:
“ssh [email protected] ‘ls /home/user’”
*The above example wants to execute the command “ls /home/user” at the remote computer with an IP address “1.1.1.1” using the credentials of the user “user”
*The result of the command after its execution when the correct password is given will be displayed on your desktop’s linux cli, this means that with this specific command whatever is displayed are not your local files but the files of the remote user “user”; any known commands can be remotely executed this way as long as the correct user credential is typed
--
-4. As per the previous posts of opening and closing some of the most important programs on Linux Mint, what if you want to open the program WRITER (the equivalent of Microsoft Word) at the remote computer? Here it is:
*To open the program WRITER on the remote computer, type at the linux cli:
“ssh -X [email protected] ‘libreoffice –writer’”
*The above command will open the program “WRITER” on the remote computer with an IP address 1.1.1.1, said program once opened will be displayed at your own and local desktop
*Since you are opening a program that is located remotely, once you save anything on that program the resulting file is saved at the remote computer and not at your local desktop eventhough you are working locally as displayed by your monitor; this is so because ssh is just wanting to display whatever is seen remotely once the remote command is executed
--
-5. Connect to a remote computer using two stage ssh connection, said remote computer you can not ssh anymore directly:
*First, connect firstly to a remote computer that you have ssh access into:
“ssh [email protected]”
*Once supplying the password of the user “user”, you will be prompted with the cli of the remote computer at IP address 1.1.1.1; at this point of your connection, you can connect to another remote computer that is accessible by the remote linux computer that you just successfully connected, just type again this command at the remote computer’s cli:
“ssh [email protected]”
*Once you supply the correct password of the user “user2” of the remote computer with IP address 2.2.2.2 as seen by 1.1.1.1, another linux cli will appear at your local linux clicking
*In this example you are connecting thru ssh in double hops already, because the remote computer with IP address 2.2.2.2 is inaccessible from your local desktop if you connect to it directly, meaning you can only connect to 2.2.2.2 thru ssh if you connect to 1.1.1.1 first
As SSH is one of the most versatile utility in the computing world, there are lots of safeguards as to its proper implementation and good use. Do not worry for now, as my main intent is to teach you very basic SSH first. I can guarantee you it is very safe, provided you knew what you are doing.
That is why this tutorial to be SSH-safe.
Previous Post URL:
https://steemit.com/knowledge/@lightingmacsteem/auswy-i-t-spices-the-linux-way