Как перезапустить службу SSH?
Продвигаясь вперед с systemd , начиная с Ubuntu 15.04 , теперь вы используете этот синтаксис для остановки, запуска или перезапуска служб:
До 15.04:
Он должен быть таким же простым, как (проверено на новой установке с openssh-server)
Поскольку он использует выскочку , это Лучше всего сделать это вместо использования /etc/init.d/ssh, службы или прямого вызова sshd. Обязательно запустите обе команды; если вы получите сообщение об ошибке stop ssh , все равно запустите ssh и посмотрите, что там написано — служба уже может быть остановлена.
(я бы рекомендовал stop ] / запустить поверх перезапустить , если вы не пытаетесь перезапустить систему удаленно. Если ssh уже остановлен, перезапуск не запустит , а не это.)
Если эти команды не работают, вы, вероятно, либо столкнулись с ошибкой, либо слишком сильно повозились со своей системой, и в этом случае вы, по крайней мере, знаете, в чем проблема.
Команда для перезапуска службы ssh :
Начиная с Ubuntu 15.04, Canonical больше не поставляет выскочку по умолчанию .
Таким образом, команды start , stop и restart больше не доступны.
Правильный метод перезапуска службы SSH (или любой другой службы) сейчас является одной из двух следующих команд:
Я думаю, что ошибка неизвестного экземпляра вызвана тем, что SSH не запущен.
Чтобы узнать, запущен ли демон SSH, вам следует см. что-то вроде:
В любом случае просто попробуйте любой из этих:
sudo /etc/init.d/ssh start
sudo start ssh
Сначала проверьте, работает ли sshd, используя следующее:
Вы должны увидеть что-то вроде:
Если вы не видите строку для / usr / sbin / sshd -D , тогда sshd либо никогда не запускался, либо аварийно завершился, что потребует f urther, чтобы выяснить причину.
Если вы видите эту строку, выполните следующую команду:
Это должно напечатать идентификатор процесса sshd, поэтому в этом случае вы должны увидеть:
Если содержимое sshd. pid не соответствует идентификатору процесса запущенного экземпляра sshd, значит, что-то его неправильно перезапустило. Но какие бы подробности вы здесь ни нашли, они должны направить вас на верный путь. Либо он дает сбой, либо неправильно перезагружается, либо вообще не запускается.
На рабочем столе Ubuntu:
Сначала проверьте статус службы:

должен показать: — Активно: активно (работает) Если она работает, в этом нет необходимости чтобы перезапустить его. Если вы все еще хотите перезапустить его, Ubuntu вызывает службу ssh, а не sshd.
Но если это не рабочий стол Ubuntu, с помощью интерфейса командной строки:
Служба также управляется выскочкой, а не sysvinit. Таким образом, вы найдете его в /etc/init/ssh.conf вместо /etc/init.d/ssh.
Если вы хотите изменить некоторые настройки (например, порт прослушивания и разрешение на вход root), отредактировав файл конфигурации с помощью команды:
На рабочем столе Ubuntu вы можете использовать gedit вместо nano:

Наконец, примените изменения, перезапустив или перезагрузив SSH:
Если описанное выше по-прежнему не работает, введите следующее:
Если все вышеперечисленное не помогло, попробуйте перезапустить систему ubuntu:
colematt / howto-start-stop-ssh-server.md
For systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above servers, run:
Ubuntu Linux: Stop OpenSSH server
Type the following command:
For systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above servers, run:
Ubuntu Linux: Restart OpenSSH server
Type the following command:
For systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above servers, run:
Ubuntu Linux: See status of OpenSSH server
Type the following command:
For systemd based Ubuntu Linux 16.04/18.04/20.04 LTS or above servers, run:
How to Restart the SSH Service?
SSH is an open-source client-server architecture that enables encrypted system connection. It is also known as the practical implementation of SSH protocol. This connection can be utilized to transfer files and access the terminal.
It is mainly used for the encrypted connection that securely transfers information between the server and the client. Sometimes the SSH service slows down or may generate an operational error. So restarting it in such scenarios and performing the task smoothly is recommended.
This guide lists down the possible ways to restart SSH Service on Linux with the following highlights:
- Method 1: Using the “systemctl” Command
- Method 2: Using the “service” Command
- Method 3: Using “/etc/init.d” Directory
Method 1: Using the “systemctl” Command
The “systemctl” command-line tool manages the “systemd” initialization system and service manager. It allows the user to interact with the services using options such as “start”, “enable”, “stop”, “disable”, and view.
Restart SSH Service
Execute the “systemctl” command followed by the “restart” options and the superuser privileges i.e “sudo” to restart the “SSH” service:

The error-free output confirms that “SSH” service is restarted.
Check SSH Service Status
If the user wants to check the current status of the “SSH” service, then use the “status” with the “systemctl” command:

The SSH service is now in an “active (running)” state.
Method 2: Using the “service” Command
The other tool is the “service” command utility utilized to execute a SystemV init script in the in /etc/init.d directory. It can also start, stop, restart, reload, and enable the services like the systemctl command.
Restart SSH Service
Type the “restart” flag alongside the “sudo” and “service” commands for restarting the “ssh” service in the following way:

It provides the same output as the “systemctl” command.
Method 3: Using “/etc/init.d” Directory
The “etc/init.d” is the directory that contains the start and stop scripts to manage the start, stop, restart, and reload process of the service at boot time. It requires the superuser privileges to access and control the script using the terminal manually.
Restart SSH Service
Specify the name of the “SSH” service with the “restart” control command in the terminal to restart it:
How can I restart the SSH daemon on Ubuntu?
When I type in service sshd restart I get a sshd: unrecognized service error.
I do have, in /etc/ssh/ a file sshd_config that I use to set config. I can also putty into the Ubuntu box (it is remote).
When I type in /etc/init.d/sshd restart I get No such file or directory
Under /usr/sbin/ there is an sshd file, but it is binary.
Is something wrong with my sshd? What do I do to fix this? To be clear, I want to be able to type service sshd restart (like all the online tutourials say) to be able to, well, restart my sshd. So that my port changes take effect.