How to set up remote login with SSH on CentOS?

To set up SSH remote login on CentOS, you need to follow the steps below:

  1. Install SSH server: Enter the following command in the terminal window to install the SSH server:
sudo yum install openssh-server
  1. Start SSH service: Enter the following command in the terminal window to start the SSH service:
sudo systemctl start sshd
  1. To set SSH service to start automatically on boot, input the following command in the terminal window:
sudo systemctl enable sshd
  1. Configure the firewall: By default, the firewall on CentOS blocks SSH connections. If you are using firewalld, you will need to open the SSH port. Enter the following command in the terminal window to open the SSH port:
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload
  1. To obtain the IP address of a CentOS server: Enter the following command in the terminal window to get the IP address of a CentOS server:
ip addr
  1. Connect to a CentOS server using SSH from a remote computer: Open the SSH client and use the server’s IP address and username to connect. For example, use the following command to connect to the server:
ssh username@server_ip_address

Note: replace “username” with your actual username on the CentOS server, and replace “server_ip_address” with the actual IP address of your CentOS server.

After the setup is complete, you should be able to remotely login to the CentOS server via SSH.

bannerAds