Сервер SSH на уровне выполнения 3

5090
Godric Seer

Я пытался настроить ssh-сервер на своем рабочем столе для удаленного доступа и столкнулся с несколькими проблемами. Первое, что я обнаружил, это то, что sshd не запускается при загрузке. Как только я бегу:

sudo service sshd start 

вручную я могу подключиться к компьютеру через ssh, поэтому я знаю, что демон ssh установлен правильно. Теперь я просто хочу, чтобы это началось при загрузке.

Посмотрев на это я нашел в

/etc/rc.d/rc3.d 

Я нашел скрипт

K##sshd 

Или что-то вдоль этих линий. Я считаю, что K подразумевает, что при входе на уровень выполнения 3 он выключает sshd. Все, что мне нужно сделать, чтобы начать, - это создать файл S ## sshd, чтобы перезапустить его, или есть лучший способ сделать это. Я подумал, что мне нужно получить несколько более осведомленных мнений, прежде чем я начну переименовывать и создавать случайные файлы.

2

3 ответа на вопрос

6
Rich Homolka

I believe the K implies that when entering run-level 3, it is shutting down sshd

Yes. K is for Kill.

This is old SystemV style startup. The base scripts are all in init.d, and there are various symlinks with specific naming conventions (S00..., K99...) in the rc?.d directories where they're actually run from.

When you change runlevels, say from 1 to 3, the init process spawns a script that goes into the directory for the old runlevel (/etc/rc.d/rc1.d/) and run all the scripts that start with K as

K_NUMBER_some_service stop 

Then you go to the directory for the new runlevel (/etc/rc.d/rc3.d in this case) and run all the scripts that start with S as

S_NUMBER_some_service start 

The scripts are run in alphabetical order, the order usually determined by the NUMBER which ranges from 00-99. The order is important - you don't want to start sshd before you start networking.

In theory, if you know how to determine the number/order it should be run as, you could do the symlinks manually. Most scripts have this order number as a comment (try: head /etc/rc.d/init.d/sshd). But you're much better off using the proper tools for the job. On Redhat, there is ntsysv, and also system-config-services. If you wanted to, you could even use the command line tool chkconfig. I think

chkconfig --level 2345 sshd on 

would do what you want. Verify with chkconfig --list sshd

ntsysv сделал это, я думаю, что копаться в сырых файлах с моим уровнем опыта не было разумным способом сделать это. Godric Seer 11 лет назад 0
2
ott--

Redhat uses the ntsysv tool to enable/disable services for the rcN.d directories.

0
Maxwell S.

if you looking to login in runlevel 3 (which is Multi-User mode, console logins only), all what you want to do is $ sudo init 3 . another way to do that is to add the kernel parameter "3", and to when you grub is booting press "e" to modify the kernel boot option.

WARNING: applying this to machine running on runlevel 5 (Multi-User mode, with display manager as well as console logins ) will kill X11 and force you to login in console mode.

Похожие вопросы