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

MacOS 15 Sequoiaアップデート後のSSH接続問題の解決方法

Last updated at Posted at 2024-09-16

MacOS 15 Sequoiaにアップデートした後、SSH接続ができなくなる問題が発生しました。SSHポートを別のポートに変更して使用していましたが、アップデート後にポート設定がデフォルトに戻ってしまったのではないかと思い、確認してみました。

ssh: connect to host port 00000: Connection refused

/etc/sshd/sshd_configの修正

sudo vim /etc/ssh/sshd_config

確認してみると、デフォルト設定に初期化されていました。管理者権限でsshd_configファイルを開き、portの部分のコメントアウトを解除し、希望のポート番号に修正します。

sshディレクトリには、ssh_configとsshd_configの2つのファイルがあります。ssh_configは内部から外部への接続設定、sshd_configは外部から内部への接続設定です。

Port 00000 # 希望のポート番号に変更
PasswordAuthentication no # optional パスワード認証を無効にし、RSA鍵のみでのアクセスを強制

/etc/servicesの修正

sudo vim /etc/services

ここでsshを探し、ポート番号を修正します。vimでsshという文字列を検索したい場合は、/sshと入力します。

# ssh 22/udp
# ssh 22/tcp
ssh 00000/udp
ssh 00000/tcp

SSHポート変更の適用

sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
# または
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

SSH接続

sshコマンドで直接アクセスするか、~/.ssh/configファイルの設定をしてSSH接続します。

ssh (username)@(hostname) -p 00000

または

Host hostname
    HostName XXX.XXX.XXX.XXX
    User username
    Port 00000
    IdentityFile ~/.ssh/XXXXXXX.pem

以上の手順で、MacOS 15 Sequoiaアップデート後のSSH接続問題を解決することができます。ポート設定が初期化されている可能性があるため、必ず確認と再設定を行ってください。

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