While we’re still on the subject of networks, I thought I’d stick in a few remote system administration tools.
You’ll let me get away with claiming that these are network-related, because by definition of “remote”, there has to be some sort of network connection involved, right?
These commands will allow you to perform various administrative tasks on Linux machines that you do not have physical access to, whether that’s because they’re in a far off country, or because you can’t be bothered to get out of your chair and walk across the room. Both are perfectly valid excuses, provided — in the case of the latter — that you’re recovering from running a very recent marathon.
The ssh Command
The ssh command is a remote login program, the command-line version of the OpenSSH Secure Shell client.
It is used to log in to remote machines/servers to execute commands on those systems.
To use the command, simply follow it with the name or IP address of the remote host:
If you need to log into the remote host with a different username than what you are using currently, you can specify it with an @ sign:
After being prompted for — and typing in — the correct password, you’ll be logged into the remote host and can execute all sorts of commands.
If you ssh on a regular basis, and/or keep multiple terminal windows or tabs open at a time, watch that you don’t start executing commands on the remote host that you meant to execute locally — and vice versa!
logout when you’re finished, to return to your local system.
The telnet Command
The telnet command is used to communicate with another host using the TELNET protocol.
It differs from ssh in that it is older and does not encrypt its data. Unlike ssh, telnet sends even your password across the network in plain text.
I would advise everyone to stick with ssh!
The scp Command
The scp “secure copy” command is a remote file copy program.
The scp command can be used either to copy files from the local host to a remote host, or from a remote host to the local host. In short, it can either upload or download a file.
The syntax is:
scp what where
(The current location of the file is specified first; the location to put the file is specified second.)
To log into the remote host with a different username than what you are using on your local host, specify the username with an @ sign:
To specify the full path to a remote file (or to where a file should be copied remotely), use a full colon after the domain or IP address, followed by the full pathname to the file:
scp image.png firstname.lastname@example.org:/full/path/to/file/image.png
scp email@example.com:/full/path/to/file/image.png .
The rcp Command
The rcp command stands for “remote file copy”.
As opposed to the scp command, rcp is not secure (encrypted), and so any details (password, etc.) are sent in plain text.
I would advise everyone to stick with scp!
The wget Command
The wget command is a “web get” utility that downloads files from a remote location.
It downloads recursively, and so can recreate entire directory structures and/or websites on the local host.
If the command is not first available, you may have to install it:
dnf install wget
To download a file or directory into the local host’s current/working directory, a single argument can be given, that of the remote file or directory:
There are several useful options available.
The -b option runs wget in the background, freeing up your comment prompt in the meantime.
The -c option will continue/finish downloading a partial download that had previously been running.
The –limit-rate= option allows a download speed to be specified, that will not be exceeded.
The -np “no parent” option ensures that nothing from the parent directory will be retrieved.
The –progress= option allows either “dot” or “bar” to be specified as the type of progress indicator shown.
The -r option turns on recursive retrieval (if it is not already on by default).
The –spider option causes the command to only check if a file is available, but does not download it.
Check out the manual page, and/or begin to experiment, to get the desired result(s).
The curl Command
The curl command will “transfer a URL”. It transfers data from or to a server, using one of the supported protocols, with little to no user interaction.
The most basic example of using curl is to specify a url, and watch as the HTML (usually interpreted by a browser to create an aesthetically-pleasing webpage) is printed across your screen.
The output can be redirected into a file instead of being sent directly to the command line. Do you remember the > redirect operator?
curl http://slashdot.org/ > slashdot.html
There is also a curl option (-o) that allows a file to be specified for the output to be saved in.
curl -o slashdot.html http://slashdot.org/
Use the -: option to separate multiple arguments and their options, to run multiple instances at once.
curl -o slashdot.html http://slashdot.org/ -: amazon.html http://amazon.com/
There are many other things that the curl command can do; it’s all written out in the manual page, so I won’t attempt to recreate that here.
Curl can upload to FTP servers, download from FTP servers, send emails, download via proxy servers, and much more.
The rsync Command
The rsync command should not be forgotten, as it stands for “remote sync” and so qualifies under our topic.
I have previously previously written about rsync in some detail, so I would advise hopping over to that page to explore it further.
With all of the commands now available, you can see that remote administration can be performed very quickly and easily.
On an average day, I use ssh multiple times a day, while I use scp only on occasion.
What remote administration commands do you use on a regular basis?