使用私钥连接 macos 上的 ssh server
1、首先编辑 macos 系统下的 ssh 配置文件:sudo vi /etc/sshd_config
进行以下设置:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
2、把 /etc/ssh_rsa_key.pub 放到 ~/.ssh/authorized_keys
sudo cp /etc/ssh_rsa_key.pub ~/.ssh/authorized_keys
3、修改权限
sudo chmod 600 ~/.ssh/authorized_keys
4、重启 ssh 服务
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
5、客户端连接 ssh server
ssh -i ~/.ssh/private_key username@xxx.xxx.xxx.xxx