がべーじこれくしょん

技術系とかいろいろ

Ubuntu 16.04 LTSでssh.serviceがunrecognized serviceと言われたときの対処法

執筆・創作活動への支援をぜひお願いします🙏
Buy Me A Coffee

事の始まり

Ubuntu 16.04 LTSが動いているPCに対してSSH接続を試みたところ、以下のようなエラーを吐いて拒否された。

$ ssh hoge@192.168.2.103
ssh: connect to host 192.168.2.103 port 22: Connection refused

「どうせsshdが落ちてるんだろw」

そう思ってサービスの状態を確認しようとしたところ…

$ sudo service sshd status
●sshd.service
  Loaded: not-found (Reason: No such file or directory)
  Active: inactive (dead)

どうやら認識すらされてないようです。

対処法

openssh-serverを再インストールしましょう。

$ sudo apt-get purge openssh-server
$ sudo apt-get install openssh-server

これで起動できるようになったはずです。それでは、快適なインフラライフを…:+1:

$ sudo service sshd start
$ sudo service sshd status
●ssh.service - OpenBSD Secure Shell Server
  Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
  Active: active (running) since ...

参考

https://askubuntu.com/questins/265982/unable-to-start-sshd