Linux9 SSH ルート ログインを有効/無効にする設定 sshd_configで動作しない

Linux9 SSH ルート ログインを有効/無効にする設定 sshd_configで動作しない場合に参考になる情報です。

 

以下は参考情報です。

 

まずは、ユーザー作成です。※一部変更しています

 

# adduser testuser
# passwd testuser
Changing password for user testuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Edit /etc/sudoers file by using vim text editor or you can execute visudo command to do the same.

# visudo
Add following line in this file to grant sudo permissions to your Admin user.

testuser   ALL=(ALL)       ALL

 

 

続いて、SSH ルート ログインを無効にするには

 

SH 設定ファイルは/etc/sshディレクトリにあります。

vim テキストエディタを使用して、 01-permitrootlogin.confファイルを編集します。このファイルは、最小限インストールされた Rocky Linux 9 オペレーティング システムにすでに存在しています。他の Linux ディストリビューションの場合は、このファイルの作成が必要になる場合があります。

 

# vi /etc/ssh/sshd_config.d/01-permitrootlogin.conf


このファイル内で次のディレクティブを見つけて設定します。

PermitRootLogin no

 

SSH デーモンを再起動して、構成の変更をロードします。

# systemctl restart sshd.service

 

etc/ssh/sshd_config.d/01-permitrootlogin.confがLinux9からの設定方法になります。

 

「参考」

https://www.centlinux.com/2023/05/disable-ssh-root-login-in-rocky-linux-9.html

 

Anker PowerCore 10000 (10000mAh 大容量 モバイルバッテリー)【PSE技術基準適合/PowerIQ搭載】 iPhone&Android対応 (ブラック)