Secure shell protocol
Secure shell (SSH) protocol is a network protocol that is used to establish an encrypted communication between a server and a client, using the TCP protocol. The SSH service is TCP-based, and listens, by default, on port 22. In general, a public-private key pair allows users to log in to a system without requiring a password. The public key is present on all systems that require a secure connection, while the user keeps the private key in a secure place. On the target systems, the public key is verified against a list of authorized keys that are allowed to remotely access the server. SSH can be compromised when the public key is not cryptographically strong enough, and can be guessed.
- To start the ssh service, use the following:
service ssh start
- To check whether the service is running properly, use the following:
netstat -antp|grep sshd
# or
service ssh status
- To enable the service to start on boot, use the following:
systemctl enable ssh
- To stop the SSH service, use the following:
service ssh stop
- To connect to a remote SSH server, use the following:
ssh [username@IP]
- To connect to an SSH server that is using a custom port number (not 22), use the following:
ssh -p [port number]
- To generate a new SSH key, use the following:
dpkg-reconfigure openssh-server
- To allow root remote login into SSH, perform the following:
- Open the file, /etc/ssh/sshd_config
- Change the PermitRootLogin parameter to Yes, and restart the SSH server
As you may have guessed, to manage any service, you can use the following commands:
service [service name] start (To start the service)
service [service name] stop (To stop the service)
service [service name] restart (To restart the service)
service [service name] status (To get the status of the service)