0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

sshのポート番号変更方法

0
Last updated at Posted at 2024-04-13

初めに

sshのポート番号の変更がしたくなったので、解説をしていきます。

サーバーOS

CentoOS Stream X_86_64

やり方

サーバーのコントロールパネルでやる設定

スクリーンショット 2024-04-13 15.37.06.png

まず、コントロールパネルに行ってもらってパケットフィルターを設定を押してください。

スクリーンショット 2024-04-13 15.37.32.png

自分が設定したいポートを設定します。

設定を保存してもらって終了です。

ターミナルの設定

sshサーバーに接続してrootユーザーになってください。

cd /etc/ssh

でsshディレクトリに行ってください。
そこでsshの設定ファイルである。sshd_configのバックアップを取ります。

cp sshd_config sshd_config.old

上書きするかの確認を取られるかもですが、許可してください。

vi sshd_config

でsshd_configの設定をしていきます。

Port ~

みたいなところがあると思うので、コントロールパネルで設定した番号を指定してください。

設定を反映

systemctl restart sshd

でsshの設定を反映します。

テスト

ローカルからsshでサーバに接続できるかを確認します。

ssh -p ポート番号 ユーザー名@IPアドレス

を叩いて、パスワードを入力すると接続できます。

一応22番で接続できないことを確認しておきます。

ssh ユーザー名@IPアドレス

を叩いてもらって

ssh: connect to host ~~~ port 22: Connection refused

と出れば終了です。
お疲れ様でした。

追記

22番ポートが使えないことを確認したら
さくらvpsのサーバー詳細からパケットフィルタを設定で
接続ポートから22番を外しておいてください。

参考文献

公式からおすすめされたサイトを参考にしたのですが、コントロールパネルの説明がなかったので、少し残念でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?