0
1

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 3 years have passed since last update.

centos6でのSSHのポート変更

Last updated at Posted at 2021-04-28

centos7に慣れてきて、centos6を忘れてかけてきた今こそメモ

SSHのデフォルトポート22を3000に変更してみる

sshd_configの設定

$ vi /etc/ssh/sshd_config

# Port 22
Port 3000

iptablesの設定

バックアップをとる
$ iptables-save > 20210428_iptables.txt

コピーを作成して、編集する
$ cp 20210428_iptables.txt 20210428_iptables_new.txt
$ vi 20210428_iptables_new.txt
22の部分を3000に変更(詳細は略)

修正をiptablesに反映
$ iptables-restore < 20210428_iptables_new.txt
$ /etc/init.d/iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]

サービスを再起動して実反映
$ service sshd restart
$ service iptables restart

※注意。このあと、最終確認するまで作業中のターミナルは閉じないこと。
失敗した場合にログイン出来なくなるため。

別ウィンドウ、新しいポートでのSSH接続を試行する

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?