问题
我安装了openssh服务器,指向端口22,测试运行,并在Windows XP机器上安装Putty,连接被拒绝,
$ sudo -s
$ service ssh status
ssh stop/waiting
$ service ssh start
ssh start/running, process 2212
$ service ssh status
ssh stop/waiting
显然ssh已经停止或正在等待。
$ ssh localhost
ssh: connect to host localhost port 22: Connection refused
我检查了ufw (防火墙),看看端口22是否在运行。
$ sudo ufw status
Status: active
To Action From
22 ALLOW Anywhere
22/tcp ALLOW Anywhere
22 ALLOW Anywhere (v6)
22/tcp ALLOW Anywhere (v6)
sshd_config
只显示端口22
/usr/sbin/sshd -p 22 -D -d -e
答案1
你的/etc/ssh/sshd_config
文件中有重复的部分。
重命名sshd_config
文件
sudo mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old
重新安装openssh-server
获取原始文件:
sudo apt-get install --reinstall openssh-server
看看能不能用。
答案2
你可以运行sshd -t
和sshd_config
显示错误;
root@sh1:/etc/ssh# sshd -t /etc/ssh/sshd_config line 102: Directive 'UsePAM' is not allowed within a Match block
相关文章