Summer training at Goeduhub Technologies-Jaipur
Register for Free Certified Workshop on RTU Python Lab (VI SEM):: 01-03-2020 ||  Career options for aspiring CS/ITECEEE or EIC or EEE Engineers
0 like 0 dislike
in Tutorial & Interview questions by Summer Trainee (7k points)

1 Answer

0 like 0 dislike
by Summer Trainee (7k points)
Best answer

A secure shell is used to remotely access a server from a client over an encrypted connection. OpenSSH is used as an alternative to Telnet connections that achieve remote shell access but are unencrypted. The OpenSSH Client is installed on most GNU/Linux distributions by default and is used to connect to a server. These examples show use how to use the SSH suite to for accept SSH connections and connecting to another host.

Connecting to a remote server

To connect to a server we must use SSH on the client as follows,

# ssh -p port user@server-address

port - The listening ssh port of the server (default port 22).

user - Must be an existing user on the server with SSH privileges.

server address - The IP/Domain of the server.

For a real world example lets pretend that you're making a website. The company you chose to host your site tells you that the server is located at on a custom port of 2020 and your account name usr1 has been chosen to create a user on the server with SSH privileges. In this case the SSH command used would be as such

# ssh -p 2020

If account name on the remote system is the same as the one one the local client you may leave the user name off.

So if you are usr1 on both systems then you my simply use instead of

When a server you want to connect to is not directly accessible to you, you can try using ProxyJump switch to connect to it through another server which is accessible to you and can connect to the desired server.

# ssh -J usr1@ usr2@ -p 2222

This will let you connect to the server (running ssh on port 2222) through server at (running ssh on port 2020). You will need to have accounts on both servers of course. Also note that the -J switch is introduced in OpenSSH version 7.3.

Installing OpenSSH suite

Both connecting to a remove SSH server and accepting SSH connections require installation of openssh
# apt-get install openssh
Arch Linux:
# pacman -S openssh
# yum install openssh

Configuring an SSH server to accept connections 

First we must edit the SSH daemon config file. Though under different Linux distributions this may be located in different directories, usually it is stored under /etc/ssh/sshd_config
Use your text editor to change the values set in this file, all lines starting with # are commented out and must have this character removed to take any effect. A list of recommendations follow as such.
Port (chose a number between 0 - 65535, normaly greater than four digits)
PasswordAuthentication yes
AllowUsers user1 user2 ...etc
Note that it is preferable to disable password logins all together and use SSH Keys for improved security as explained in this document.

Passwordless connection (using a key pair)

First of all you'll need to have a key pair. If you don't have one yet, take a look at the 'Generate public and private key topic'.
Your key pair is composed by a private key (id_rsa) and a public key ( All you need to do is to copy the public key to the remote host and add its contents to the ~/.ssh/authorized_keys file.
One simple way to do that is:
ssh <user>@<ssh-server> 'cat >> ~/.ssh/authorized_keys' <
Once the public key is properly placed in your user's home directory, you just need to login using the respective private key:
ssh <user>@<ssh-server> -i id_rsa

Generate public and private key 

To generate keys for SSH client:
ssh-keygen [-t rsa | rsa1 | dsa ] [-C <comment>] [-b bits]
For example:
ssh-keygen -t rsa -b 4096 - C
Default location is ~/.ssh/id_rsa for private and ~/.ssh/ for public key.
For more info, please visit

Disable ssh service

This will disable the SSH server side service, as if needed this will insure that clients cannot connect via ssh
sudo service ssh stop
sudo systemctl disable sshd.service
sudo /etc/init.d/ssh stop
sudo systemctl disable sshd.service
Arch Linux
sudo killall sshd
sudo systemctl disable sshd.service


Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
 Go to your Branch CSE or IT | ECE | EE, EIC or EEEMECE
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-KOTA | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
About Us | Contact Us   Social::   |  |