What is SSH?
The Secure Shell Protocol (SSH) is a cryptographic network protocol that allows network services to be operated safely over an unsecured network.
Remote login and command-line execution are two of its most noteworthy applications.
SSH apps use a client-server architecture to connect an SSH client to an SSH server.
Difference Between Telnet & SSH
Telnet :
It is a remote access protocol
It is an unsecured remote access protocol
It uses port no 23
Transfer the data in plain text
Not recommended for public networks, but used for private networks.
SSH :
It is a remote access protocol
It is a secured remote access protocol
It uses port no 22
Transfer the data in an encrypted format
Recommended for public networks
SSH server pre-request :
SSH package installed
SSH status should be active --> systemctl status sshd
Check 22 port is open --> netstat -tunlp|grep 22
Check if service is enabled --> systemctl enable sshd
Check if service is started / active --> systemctl start sshd
How to know if any system is accessed remotely?
who - Displays information about all users currently on the local system.
finger - Find information about computer users.
Where the keys are stored on the server side?
/etc/ssh
Where the keys are stored on the client side?
/<homedirectory>/.ssh/
Server Configuration File :
The sshd_config file specifies the locations of one or more host key files (mandatory) and the location of authorized_keys files for users.
Location of sshd_config --> /etc/ssh/sshd_config
The root is initially disabled for security reasons.
Max session --> Numbers of connections can be established remotely.
Allow users --> Users you want to allow connections.
Deny users --> Users you want to deny connections.
How to control the machine to establish the connection remotely??
/etc/host.deny
e.g.
sshd : 172.10.21.10 --> Specfic IP
sshd : 172.25.0.0/255 --> Specfic network
sshd ALL --> No one can establish a connection remotely
If ssh is not working what can be the possible reasons?
Troubleshooting :
Service OFF
Password wrong
Token - NO
Max session
Deny user
Public Authentication
Port Closed
N/W denial
Root user NO PERMIT
How to connect to the machine remotely?
#ssh <username>@<IP/hostname>
ssh ansible@172.12.2.4