macos 更改ssh端口

/ 0评 / 0

编辑默认/System/Library/LaunchDaemons/ssh.plist 提示只读

不进入macOS Recovery 更改方法

sudo cp /System/Library/LaunchDaemons/ssh.plist /Library/LaunchDaemons/ssh2.plist

sudo vim /Library/LaunchDaemons/ssh2.plist

更改两处

<key>Label</key>
<string>com.openssh.sshd2</string>

<key>SockServiceName</key>
<string>2222</string>
<key>Bonjour</key>

开启 sudo launchctl load -w /Library/LaunchDaemons/ssh2.plist

关闭 sudo launchctl unload /Library/LaunchDaemons/ssh2.plist

查看监听端口 sudo lsof -i -P -n

查看ssh命令是否运行 sudo launchctl list | grep sshd

发表评论

邮箱地址不会被公开。 必填项已用*标注