Debian SSH 与其他系统的互联实践
一、网络与连通性准备
sudo firewall-cmd --add-port=22/tcp --permanent && sudo firewall-cmd --reload。二、在 Debian 上启用 SSH 服务端
sudo apt-get update && sudo apt-get install openssh-serversudo systemctl start ssh && sudo systemctl enable sshPermitRootLogin noPubkeyAuthentication yesPort 2222,修改后重启服务:sudo systemctl restart sshssh user@debian_ip -p 22(或自定义端口)三、从常见系统连接 Debian 的 SSH
ssh user@debian_ip -p 22ssh -i ~/.ssh/id_rsa user@debian_ip -p 22ssh user@debian_ip -p 22四、免密码登录与常用文件传输
ssh-keygen -t rsa(默认生成 ~/.ssh/id_rsa 与 id_rsa.pub)ssh-copy-id user@debian_ip -p 22cat ~/.ssh/id_rsa.pub | ssh user@debian_ip "cat >> ~/.ssh/authorized_keys"eval $(ssh-agent)ssh-add ~/.ssh/id_rsa(输入一次密码后,后续会话免密)scp file user@debian_ip:/pathscp -r dir user@debian_ip:/pathHost *ServerAliveInterval 180五、常见问题与排查
sudo systemctl status ssh,异常时查看日志 sudo journalctl -u ssh。ping 测试;虚拟机确认网络模式与端口转发规则。PermitRootLogin yes 并重启服务(不建议生产环境开启)。