奇怪的SSH问题 – 它甚至都不会启动
我最近得到了Ubuntu 12.04 Precise,它启动并运行了一些MediaWiki软件,盒子和路由器上的静态IP,甚至可以通过手机访问主页面。 一切似乎都很棒……
然后我想终于摆脱显示器和键盘并通过SSH远程登录。
我安装了openssh-server,让一切都指向端口22进行测试运行并在我的Windows XP机器上安装putty。 我拒绝了连接。 回来并开始检查Ubuntu安装本身…(从这一点开始我已经根目录了)
$ 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
ssh根本没有使用正确的IP地址吗? 我只是不明白我在这里做错了什么。 当这个启动并运行时,我将def更改端口号,但是现在,在使用putty的测试运行成功之前,我不想过多地使用默认安装。
编辑:
这是我的sshd_config文件和我的ssh_config文件。
命令/usr/sbin/sshd -p 22 -D -d -e
返回:
/ etc / ssh / sshd_config第159行:已定义子系统’sftp’。
编辑: @phoibus移动sshd_config文件并重新安装就行了!
服务ssh状态
上面的命令显示ssh现在正在运行,我现在可以通过putty从我的windows xp计算机远程登录。 非常感谢! 我现在可以用我的显示器做其他事了!
您在/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
看它现在是否有效。
我的问题也是一个设置问题,但我无法弄清楚我的哪些更改是问题所在。 挖掘一下后,您可以运行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
这意味着“匹配块”设置需要位于sshd_config
文件的末尾。