Category Archives: SSH Command

SSH Command Tips and Tricks

ssh man

SSH is some kind of an abbreviation of Secure SHell. It is a protocol that allows secure connections between computers.

In more detail we can summarize it as, ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.

ssh connects and logs into the specified hostname (with optional user name). The user must prove his/her identity to the remote machine using one of several methods depending on the protocol version used.

Few Use Case Examples

Assuming you are using any Linux(Like Ubuntu etc.) You can perform ssh command over terminal.

The simplest pattern would be of SSH command as below with minimum option.

ssh yourusername@yourserverip

You will still be asked for a password. For security reasons, it is not even possible to directly specify the password in the syntax. You will always be asked interactively, unless you start configuring the server in an advanced way like (You may have added your system public key to remote system from which you are connecting, in this way you will be only asked a few question during first time login, not the password for your ssh username using which you are logging to system).

You can specify your port too while issuing ssh command, if you do not wish to use default port(22) setting, due to any of reasons.

ssh -p portno yourusername@yourserverip

Sometimes, especially in scripts, you may want to connect to the remote server, and run a single command and then exit again.

ssh yourusername@yourserverip checkinfo

Authentication Methods

The methods available for authentication are: GSSAPI-based authentication, host-based authentication, public key authentication, challenge-response authentication, and password authentication. Authentication methods are tried in the order specified above, though protocol 2 has a configuration option to change the default order: PreferredAuthentications.

Public Key based Authentication

In most of situation you may find you are using public key based Authentication.
Public key authentication works as follows: The scheme is based on public-key cryptography, using cryptosystems where encryption and decryption are done using separate keys, and it is unfeasible to derive the decryption key from the encryption key. The idea is that each user creates a public/private key pair for authentication purposes. The server knows the public key, and only the user knows the private key. ssh implements public key authentication protocol automatically, using either the RSA or DSA algorithms.

Creating of public keys can be done using ssh-keygen command.