环境
我的测试环境是:docker中的Ubuntu 20.04.3 LTS
sudo apt update
sudo apt install openssh-server
查看服务状态
安装完成后,SSH服务将自动启动。要验证安装是否成功并且SSH服务正在运行,请键入以下命令,该命令将显示SSH服务器状态。
service ssh status
#或者
sudo systemctl status ssh
常见错误
执行以下命令后,发现报错了。
systemctl start ssh
System has not been booted with systemd as init system (PID 1). Can’t operate.
原因是你想用systemd命令来管理Linux上的服务,但你的系统并没有使用systemd,(很可能)使用的是经典的SysV init(sysvinit)系统。
尝试用以下命令替换:
Systemd commandSysvinit commandsystemctl start service_nameservice service_name startsystemctl stop service_nameservice service_name stopsystemctl restart service_nameservice service_name restartsystemctl status service_nameservice service_name statussystemctl enable service_nameservice service_name onsystemctl disable service_nameservice service_name off 参考https://segmentfault.com/a/1190000022103074
https://www.cnblogs.com/a5idc/p/13752839.html