文書の過去の版を表示しています。
ssh サーバーの設定
ssh サーバーの設定変更
以下のファイルの内容を編集する。
/etc/ssh/sshd_config
標準設定の port 22 の変更
#Port 22 Port 22022
root ユーザーのログインを禁止
#PermitRootLogin yes PermitRootLogin no
パスワードではなく鍵によるログインに変更
#PasswordAuthentication yes PasswordAuthentication no
設定の反映
sshd サービスを再起動する。
$ sudo service sshd restart sshd を停止中: [ OK ] sshd を起動中: [ OK ]
ファイヤーウォール設定
CentOS の場合
定義を追記する。
$ sudo vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22022 -j ACCEPT
Fedora の場合
許可されているサービスの確認。
$ sudo firewall-cmd --list-services mdns dhcpv6-client ssh
ssh の許可を永続的に削除
$ sudo firewall-cmd --permanent --remove-service=ssh
代わりにポート 22022 を永続的に許可。
$ sudo firewall-cmd --permanent --add-port=22022/tcp
firewalld の状態を失わずにリロード。
$ sudo firewall-cmd --reload
許可されているサービスの確認。
$ sudo firewall-cmd --list-services mdns dhcpv6-client
許可されているポートの確認。
$ sudo firewall-cmd --list-ports 22022/tcp