Linux enables ssh remote login

Linux configures ssh to enable remote login

Hello! Here is how to enable ssh in the Linux system Centos and Ubuntu environment.

1. Open SSH service on CentOS

  1. install openssh-server;
yum list installed |grep openssh-server
如果有输出,证明已经安装了openssh-server,如果没有,需要安装
yum install openssh-server
  1. Modify the sshd service configuration file
vi /etc/ssh/sshd_config
  1. Open the listening port and remove the # comment in front of it
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
  1. Allow remote login
PermitRootLogin yes
  1. Use username and password as authentication connection
PasswordAuthentication yes
  1. Start the sshd service
service sshd start

7. Configure boot self-start

systemctl enable sshd

2. Ubuntu opens ssh service and allows root login

  1. Install the ssh server, Ubuntu does not have an ssh server installed by default, you need to install it
apt-get install openssh-server
ssh客户端是默认安装的,安装包:openssh-client,apt安装
  1. Modify the sshd service configuration file, modify the /etc/ssh/sshd_config file, and modify it as follows:
vi /etc/ssh/sshd_config

Allow remote use of root account ssh login

#PermitRootLogin prohibit-password
PermitRootLogin yes
  1. Need to restart the system or sshd service
1.sudo /etc/init.d/ssh stop
2.sudo /etc/init.d/ssh start
3.sudo service ssh start
  1. After installing the ssh service, the system starts the system sshd by default, check the sshd status, if it is not started by default, modify the service to enable
sudo systemctl enable ssh

Reference article: Reference link

Guess you like

Origin blog.csdn.net/weixin_43078123/article/details/129713471