我有一台运行Ubuntu18.04LTS的机器,在这里我似乎无法让SSH服务器工作。
我使用以下方法安装了SSHServer:
sudo apt install openssh-server
但是,当我尝试启动和/或检查状态时,我得到了以下信息:
sudo systemctl start sshd
Failed to start sshd.service: Unit sshd.service not found.
。
sudo systemctl status sshd
Unit sshd.service could not be found.
我想我一定做错了什么(打错字了吗?)当我安装时,我尝试再次安装,因此:
sudo apt install openssh-server
我明白的是:
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssh-server is already the newest version (1:7.6p1-4ubuntu0.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
因此,它似乎已经安装,但由于某种原因,Ubuntu找不到它。
我不知道从这里往哪里走,所以欢迎提出任何建议。
谢谢,
艾伦。
发布于 2019-07-28 04:12:07
该服务有可能不被称为sshd。您可以尝试以下命令
systemctl -l --type service --all|grep ssh
在我的ubuntu18.04上,默认情况下该服务称为ssh。
在我的例子中,我做了
sudo systemctl start ssh
如果这不能解决问题,可以重新安装ssh。
sudo apt-get remove --purge openssh-server
sudo apt-get update
sudo apt-get install openssh-server
发布于 2019-07-28 05:58:27
systemctl -l --type service --all|grep ssh
没有返回任何东西,所以我删除并重新安装了您的建议。
我也重新启动后,重新安装,以防万一(我以前重新启动,但这没有帮助)。现在似乎没事了。如果我再试一次这个命令,我会得到:
ssh.service loaded active running OpenBSD Secure Shell server
如果我跑了
sudo systemctl status sshd
我得到:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-07-28 17:46:39 NZST; 1min 7s ago
Process: 1343 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 1337 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 1151 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 1166 (sshd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/ssh.service
└─1166 /usr/sbin/sshd -D
Jul 28 17:46:37 Ubuntu-12345 systemd[1]: Starting OpenBSD Secure Shell server...
Jul 28 17:46:39 Ubuntu-12345 sshd[1166]: Server listening on 0.0.0.0 port 22.
Jul 28 17:46:39 Ubuntu-12345 systemd[1]: Started OpenBSD Secure Shell server.
Jul 28 17:46:39 Ubuntu-12345 sshd[1166]: Server listening on :: port 22.
Jul 28 17:46:45 Ubuntu-12345 systemd[1]: Reloading OpenBSD Secure Shell server.
Jul 28 17:46:45 Ubuntu-12345 sshd[1166]: Received SIGHUP; restarting.
Jul 28 17:46:45 Ubuntu-12345 systemd[1]: Reloaded OpenBSD Secure Shell server.
Jul 28 17:46:45 Ubuntu-12345 sshd[1166]: Server listening on 0.0.0.0 port 22.
Jul 28 17:46:45 Ubuntu-12345 sshd[1166]: Server listening on :: port 22.
所以现在看来一切都还好--至少就我所知是这样。
谢谢,
艾伦。
https://askubuntu.com/questions/1161579
复制相似问题