Enable SSH on Linux: Step-by-Step Guide
To enable SSH remote login on a Linux system, you need to follow these steps:
- Make sure your Linux system has OpenSSH server installed. If not, use the following command to install OpenSSH server:
sudo apt-get install openssh-server (对于Ubuntu和Debian系统)
sudo yum install openssh-server (对于CentOS和RedHat系统)
- Confirm that the SSH service has been started. Check the status of the SSH service using the following command:
sudo systemctl status sshd
- If the SSH service is not running, use the following command to start the SSH service:
sudo systemctl start sshd
- Enable the SSH service to start automatically. Set the SSH service to start on boot using the following command:
sudo systemctl enable sshd
- Make sure that the firewall allows SSH connections. If you are using a firewall, ensure that port 22 (the default SSH port) is allowed for connection. You can add rules using the following commands.
sudo ufw allow ssh
- Now, you can connect to your Linux system using an SSH client. Use the following command to connect to the Linux server:
ssh username@ip_address
username refers to the username on your Linux system, while ip_address refers to the IP address or hostname of your Linux system.
By following the above steps, you can successfully enable SSH remote login and connect to your Linux system.