Via SSH you can connect to a remote server’s shell. This will allow you to execute commands on the external machine from your current one, managing a different server, not the one that you’re currently working on physically.
In order to execute SSH command on a remote server you need to do the following:
1. Have an external server set with Username and Password
2. Connect to the external server using
– when prompted for the user’s password enter it
How to secure your remote SSH command execution?
Since this connection is available globally many other users around the Globe can connect to your server or initiate brute-force attacks, trying to login to your server while guessing the Username / Password. To protect from this, SSH also provides the option to establish a connection not directly using SSH Keys. You generate an SSH Key on the remote server and then enable it for authentication. Then you download it on your local machine and connect using it.
ssh -i /path/to/ssh_key firstname.lastname@example.org
– when prompted for the key’s password enter it
SSH Commands Options
The commands which you run through SSH and through a Linux machine’s terminal are usually Software written to directly interact with your machine. Those commands can do different actions and the way to dictate how this happens is to add flags and options to the commands.
For example the ls command lists all the content in the current working directory.
Downloads node_modules Public Templates
Desktop Recordings Videos Documents Music
Pictures sites ‘VirtualBox VMs’
One of the options for the ls command is to display everything as a list and to also show hidden (.dot) files as well, to achieve this we provide the following options to the ls command
ls -la # l - list, a - all
drwx——. 9 root root 4096 Dec 10 11:57 .cache
drwxr-xr-x 17 root root 4096 Dec 10 11:57 .config
-rw-r–r–. 1 root root 100 Feb 12 2017 .cshrc
drwx—— 3 root root 4096 Jan 6 2018 .dbus
drwxr-xr-x 2 root root 4096 Dec 11 2017 Desktop
drwxr-xr-x 2 root root 4096 Dec 11 2017 Documents
drwxr-xr-x 2 root root 4096 Dec 11 2017 Downloads
-rw——- 1 root root 16 Dec 11 2017 .esd_auth
drwxr-xr-x 160 root root 4096 Dec 15 10:00 .esmtp_queue
drwx—— 3 root root 4096 Dec 11 2017 .gnupg
-rw——- 1 root root 620 Dec 10 11:56 .ICEauthority
drwxr-xr-x 3 root root 4096 Nov 13 2017 .local
drwxr-xr-x 2 root root 4096 Dec 11 2017 Music
-rw——- 1 root root 0 Nov 13 2017 .mysql_history
drwxr-xr-x 4 whf whf 4096 Feb 9 2018 .npm
drwxr-xr-x 2 root root 4096 Dec 11 2017 Pictures
drwxr—– 3 root root 4096 Nov 13 2017 .pki
drwxr-xr-x 2 root root 4096 Dec 11 2017 Public
drwx—— 2 root root 4096 Oct 15 20:23 .ssh
-rw-r–r–. 1 root root 129 Feb 12 2017 .tcshrc
drwxr-xr-x 2 root root 4096 Dec 11 2017 Templates
drwxr-xr-x 2 root root 4096 Dec 11 2017 Videos
There are many options to the commands which you can execute on your computer through its shell or on a remote machine via SSH. To view more information about the command you can consider its man page. This will provide information about the command, alternatively, you can also use –help in most cases