CentOS 7配置ssh
最近在虚拟机里装了好几台centos,打算全部放到xshell里边儿管理,也可以通过局域网进行连接。
首先检查是否安装了sshd,centos 7默认都有安装的。
yum list installed | grep ssh
[root@192 ~]# yum list installed | grep ssh
libssh2.x86_64 1.8.0-4.el7 @anaconda
openssh.x86_64 7.4p1-22.el7_9 @updates
openssh-clients.x86_64 7.4p1-22.el7_9 @updates
openssh-server.x86_64 7.4p1-22.el7_9 @updates
可以看到openssh-server.x86_64默认已经安装了,如果没有就yum install一下呗:)。
运行并设置守护
启动
systemctl start sshd
守护
systemctl enable sshd
查看状态
systemctl status sshd
[root@192 ~]# systemctl start sshd
[root@192 ~]# systemctl enable sshd
Created symlink from /etc/systemd/system/multi-user.target.wants/sshd.service to /usr/lib/systemd/system/sshd.service.
[root@192 ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-02-24 19:01:21 CST; 9min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 9030 (sshd)
CGroup: /system.slice/sshd.service
└─9030 /usr/sbin/sshd -D
Feb 24 19:01:21 192.168.190.121 systemd[1]: Stopped OpenSSH server daemon.
Feb 24 19:01:21 192.168.190.121 systemd[1]: Starting OpenSSH server daemon...
Feb 24 19:01:21 192.168.190.121 sshd[9030]: Server listening on :: port 22.
Feb 24 19:01:21 192.168.190.121 sshd[9030]: Server listening on 0.0.0.0 port 22.
Feb 24 19:01:21 192.168.190.121 systemd[1]: Started OpenSSH server daemon.