CentOS 7配置ssh

Chris Harris

最近在虚拟机里装了好几台centos,打算全部放到xshell里边儿管理,也可以通过局域网进行连接。

首先检查是否安装了sshd,centos 7默认都有安装的。

1
yum list installed | grep ssh
1
2
3
4
5
6
[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一下呗:)。

运行并设置守护

启动

1
systemctl start sshd

守护

1
systemctl enable sshd

查看状态

1
systemctl status sshd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[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.

  • 标题: CentOS 7配置ssh
  • 作者: Chris Harris
  • 创建于: 2023-05-09 09:12:52
  • 更新于: 2023-05-09 17:14:31
  • 链接: https://s4g.top/2023/05/09/CentOS 7配置ssh/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
此页目录
CentOS 7配置ssh