SSH Command In Linux

SSH Command In Linux

Secure Shell (or Secure Socket Shell), abbreviated as SSL, is a network protocol that enables a client to connect to a remote client or a server using a text-based interface. After an SSL connection is made, the client can manipulate the server (or the remote client) by entering commands through the client. 


The prerequisites to establish an SSL connection: 

1. An SSH Client (from where the user can access the remote server or another client) 

2. An SSH Server on the remote machine 

3. The IP Address or the name of the remote server 


1. Accessing A Remote Server: 

To connect to a remote server in Linux, the command ssh is typed followed by the IP address of the remote server. 


The name of the remote server can also be used. 


2. Specifying the Username to Access a Remote Server: 

To connect to a remote server, the username of that remote server can also be used. 



3. Changing the Port for SSH Connection: 

A port is an endpoint where a process is sent once it reaches the remote server. By default, the SSH command runs at Port 22. To connect through a different port in Linux, the -p option of the SSH command is used. 


4. Generating SSH Keys: 

To improve security, SSH uses a key-pair, one is a public key, and the other is a private key. The public key is shared with the other clients whereas the private key is kept confidential. SSH key-pairs are used to authenticate clients to servers without the use of passwords, thus giving more security. 

To generate the key-pair, the following command is used: 



5. Copy Files Remotely through SSH: 

Files can be copied remotely and securely through the SCP command of SSH. The basic syntax of the command is: 



 The command also shows the summary of the data transfer such as the rate of transfer, the time elapsed, etc. 


6. Restarting the SSH Session: 

To restart an SSH session, one of the 2 commands is used based on the Linux distribution being used: 




7. Commands in SSH: 

The commands in SSH are the same as the ones used in the local computer. The only difference is here, these commands work on the files and directories. 


i) ls - This command lists the files in the working directory of the remote machine. 


ii) cd- To navigate through the remote machine, the cd command is used. 


iii) cp - To copy a file from a source directory to destination directory, the cp command is used. The cp command can only copy and paste files inside the remote machine. 

iv) mv - To move a file from one directory to another, the mv command is used. This command also works in the remote machine only. 


v) mkdir - This command is USD to create a new directory in the remote machine. 

vi) rm - This command is used to remove a file (or directory) from the remote machine. 


vii) ifconfig - To see the networking information and the status of the network adapters of the remote machine, the ifconfig command is used. 


8. Running a Command on the Remote Machine through the Local Computer using SSH: 

To run a command on the remote machine through the local computer, the command is appended to the SSH command as follows: 


9. SSH Options 

The SSH command comes with a wide range of options. A summary of these options is- 



  • Ezee
    17-Mar-2022 03:44:59 PM

    Hi, I%u2019m sending a directory of size 13G to other servers using the SCP command. it is copying more than 36G and get No Space left on the device error.

    can you please let me know how that is possible and please visit us: