MacOS 配置 SSH
配置 SSH 服务器
开启 SSH 服务
使用图形界面配置:在系统设置中打开 系统偏好设置 -> 共享 -> 远程登录,允许所有用户进行远程登录。
使用命令行配置:
bash
sudo launchctl load -w /System/Library/LaunchDeamons/ssh.plist
配置只允许密钥登录
需要提前使用 ssh-copy-id
将本地的密钥复制到 MacOS 服务器上。
编辑 /etc/ssh/sshd_config
文件,修改以下配置:
bash
sudo vim /etc/ssh/sshd_config
配置值如下:
properties
PubkeyAuthentication yes
PermitRootLogin no
PasswordAuthentication no
PermitEmptyPasswords no
KbdInteractiveAuthentication no
UsePAM no
下面重启 SSH 服务:
bash
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist