Fedora19でsshdサービスを有効化する

いつの間にかサービスの管理がsysVinitからsystemd というものに移行してておっさん染みてしまってたことに気付いてはまった。
service/chkconfigが許されるのはいつまでなんだろう※。数多の同僚たちがキモーイとか言われたりしないか心配。

/etc/rc.d/init.d/sshdとかもう古いんだよ無いよ。

インストール後にやったこと 

1.ランレベルの変更(5->3)


個人のテスト用でWin8ProのHyper-Vで動かしてるしデスクトップとして使うつもりはないので、
runlevelを5(graphical)からmulti-userへ変更する。

/etc/inittab  ...は編集しない。けど、このファイルを眺めると
どの手順で変更すればよいか書かれてる。
シンボリックリンク/etc/systemd/system/default.targetの参照するファイルを変えてやればよいらしい。

ランレベル3(multi-user)にしたいなら、
# ln -fs /lib/systemd/system/multi-user.target   /etc/systemd/system/default.target

とりあえずshutdown -r nowとかでリブートしてGUIが起動しないのを確認。


2.sshdサービスの有効化

いきなりWindows上のTeraTermからFedoraマシンのIPアドレスに
SSH接続を試みても、接続が拒否されてしまったので、
とりあえずサービスが上がっていないことを確認する。


# systemctl  list-unit-files | grep -i sshd(出力)
...
sshd.service                          disabled
...


・sshd.serviceのステータスを確認するにはsystemctl statusを実行する


# systemctl  status sshd.service
(出力)
sshd.serice - OpenSSH server daemon
    Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled)
    Active: inactive (dead)
<date> <time> <hostname> ...直近の履歴


・有効化するにはsystemctl enableを実行する


# systemctl  enable   sshd.service
(出力)
ln -s '/usr/lib/systemd/system/sshd.service'  '/etc/systemd/system/multi-user.target.wants/sshd.service'


・有効化されたことを確認する


# systemctl  status sshd.service
(出力)
sshd.serice - OpenSSH server daemon
    Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
    Active: inactive (dead)

サービスとして有効化はされたが、今の時点で起動していない。
OS再起動すれば起動してくることが期待されるがこのままコマンドで起動させることにする。


・サービスを起動するにはsystemctl startを実行する


# systemctl  start  sshd.service


・サービスが起動したことを確認する


# systemctl  status sshd.service(出力)
sshd.serice - OpenSSH server daemon
    Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
    Active: active (running) since <Week> <Date> <Time>; ## ago
    Process: <PIDofsshd-keygen> ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
    Main PID: <PIDofsshd> (sshd)
    CGroup: name=systemd:/system/sshd.service
                  ┗<PIDofsshd> /usr/sbin/sshd -D

これでsshd.serviceが有効になったことが確認できた。

以上



 ※Fedora19からsysVinit/service/chkconfigの説明がなくなってるっぽい

http://docs.fedoraproject.org/en-US/Fedora/19/html/Installation_Guide/s1-boot-init-shutdown-administration.html
F.9. Administering services with systemd


The move to systemd also brought new administration utilities to Fedora. Administrators have the ability to start, stop, and restart services as with sysVinit, but also have access to much more information and functionality.


Expect legacy commands to be deprecated!


systemctl fully replaces traditional utilites like service and chkconfig. While some services can still be administered with these legacy commands, all services can be administered with systemctl.
/usr/bin/systemctl does most of the heavy lifting when starting and stopping services, or configuring them to run at boot. Let us look at what systemctl can do:

http://docs.fedoraproject.org/en-US/Fedora/18/html/Installation_Guide/s2-boot-init-shutdown-init.html
 http://docs.fedoraproject.org/en-US/Fedora/17/html/Installation_Guide/s2-boot-init-shutdown-init.html
http://docs.fedoraproject.org/en-US/Fedora/16/html/Installation_Guide/s2-boot-init-shutdown-init.html

今後はchkconfigとかserviceはtraditional utilitiesでsystemctlが置き換えるからなーってことらしい。

# chkconfig実行するとこんな記載がでてくる。

注記: この出力は SysV サービスのみであり、ネイティブな systemd のサービスは含ま れていません。
      systemd services. SysV 設定のデータはネイティブな systemd の設定によって上書きされます。
      systemd サービスを一覧表示するには 'systemctl list-unit-files' を使用して ください。
      特定のターゲットにおいて有効化されているサービスを確認するには、
      'systemctl list-dependencies [target]' 。


一応serviceコマンドは使えて、実際には引数をsystemctlに渡して実行するみたい。
# service sshd status
Redirecting to /bin/systemctl status  sshd.service
# service sshd enable
Redirecting to /bin/systemctl enable  sshd.service
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'


RHELに取り込まれたらもうsysVinitはバイバイだな。

コメント

このブログの人気の投稿

4.3.0 Temporary Lookup Failureでドツボってた話

tomcat起動時の環境変数でJRE_HOMEを指定するときに