我正在尝试从我的 Mac 笔记本电脑 ssh 到我的 Linux 桌面。
我ifconfig
在我的 Linux 桌面(目标机器)上运行并获取了 eth0 下列出的 IP 地址(机器通过有线连接 - 而不是无线连接)旁边的“inet addr:”
我在我的 Mac 上用这个 IP 地址执行 ping 命令,效果如预期一样好。
但是当我尝试使用相同的地址通过 ssh 连接到该机器时,我无法访问该机器:
$ ssh -A 172.28.11.243
ssh: connect to host 172.28.11.243 port 22: Connection refused
我已经在 Google 上搜索了下下一步要检查的内容,但不清楚该怎么做。如能提供任何建议,我将不胜感激。
更新1:
$service ssh status
ssh stop/waiting
更新 2:
$ps -eaf | grep sshd
rabdelaz 23832 8389 0 10:53 pts/1 00:00:00 grep sshd
从头开始:
$ifconfig
eth0 Link encap:Ethernet HWaddr 68:05:ca:16:c6:da
inet addr:172.28.11.243 Bcast:172.28.11.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26758 errors:0 dropped:0 overruns:0 frame:0
TX packets:12721 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5683822 (5.6 MB) TX bytes:2044745 (2.0 MB)
Memory:f71c0000-f71e0000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:22 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1476 (1.4 KB) TX bytes:1476 (1.4 KB)
$service ssh status
ssh stop/waiting
$sudo service ssh start
ssh stop/pre-start, process 2961
$service ssh status
ssh stop/waiting
$grep Port /etc/ssh/ssh_config
# Port 22
日志输出:
$sudo grep -i ssh /var/log/*log
[sudo] password for rabdelaz:
/var/log/auth.log:Sep 9 11:17:21 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace/configurations ; USER=root ; COMMAND=/usr/bin/ssh-add /home/rabdelaz/.ssh/deployed/2013-07-29
/var/log/auth.log:Sep 9 11:18:12 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace/configurations ; USER=root ; COMMAND=/usr/bin/ssh-add /home/rabdelaz/.ssh/deployed/2013-07-29
/var/log/auth.log:Sep 9 11:29:41 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace/configurations ; USER=root ; COMMAND=/usr/bin/ssh-add /home/rabdelaz/.ssh/deployed/2013-07-29
/var/log/auth.log:Sep 9 11:30:58 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace/configurations ; USER=root ; COMMAND=/bin/chmod 777 /home/rabdelaz/.ssh/deployed/2013-07-29
/var/log/auth.log:Sep 9 11:52:04 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz ; USER=root ; COMMAND=/bin/chmod 777 /home/rabdelaz/.ssh/deployed/2013-07-29
/var/log/auth.log:Sep 9 12:01:42 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz ; USER=root ; COMMAND=/bin/ls -lha /home/rabdelaz/.ssh/deployed/2013-07-29
/var/log/auth.log:Sep 9 12:04:18 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz ; USER=root ; COMMAND=/bin/chmod 777 /home/rabdelaz/.ssh/internal/2013-07-29
/var/log/auth.log:Sep 9 12:04:21 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz ; USER=root ; COMMAND=/bin/chmod 777 /home/rabdelaz/.ssh/external/2013-07-29
/var/log/auth.log:Sep 9 12:04:39 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz ; USER=root ; COMMAND=/bin/chmod 777 /home/rabdelaz/.ssh/internal/2013-07-29
/var/log/auth.log:Sep 11 11:54:01 bos-lpwy9 sudo: rabdelaz : TTY=pts/2 ; PWD=/home/rabdelaz/workspace ; USER=root ; COMMAND=/usr/sbin/sshd
/var/log/auth.log:Sep 11 11:54:12 bos-lpwy9 sudo: rabdelaz : TTY=pts/2 ; PWD=/home/rabdelaz/workspace ; USER=root ; COMMAND=/usr/sbin/sshd
/var/log/auth.log:Sep 11 11:54:20 bos-lpwy9 sudo: rabdelaz : TTY=pts/2 ; PWD=/home/rabdelaz/workspace ; USER=root ; COMMAND=/usr/sbin/sshd start
/var/log/auth.log:Sep 11 11:54:54 bos-lpwy9 sudo: rabdelaz : TTY=pts/2 ; PWD=/home/rabdelaz/workspace ; USER=root ; COMMAND=/usr/sbin/service ssh start
/var/log/auth.log:Sep 11 13:36:11 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/bin/apt-get install libdbi-perl libdate-calc-perl libdbd-mysql-perl libxml-easyobj-perl libdbd-pg-perl libnetaddr-ip-perl libjson-perl libconfig-json-perl libio-pty-perl libnet-ssh-perl libtext-diff-perl libwww-mechanize-perl libtext-csv-perl p4perl libxml-simple-perl liblog-log4perl-perl libyaml-libyaml-perl libdevel-stacktrace-perl libexception-class-perl libdatetime-perl libtest-deep-perl libperl-critic-perl
/var/log/auth.log:Sep 11 14:02:12 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/bin/cpan httpssh
/var/log/auth.log:Sep 12 10:56:31 bos-lpwy9 sudo: rabdelaz : TTY=pts/1 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/sbin/service ssh start
/var/log/auth.log:Sep 12 11:13:19 bos-lpwy9 sudo: rabdelaz : TTY=pts/1 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/sbin/service ssh start
/var/log/auth.log:Sep 12 11:13:23 bos-lpwy9 sudo: rabdelaz : TTY=pts/1 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/sbin/service ssh start
/var/log/auth.log:Sep 12 11:15:46 bos-lpwy9 sudo: rabdelaz : TTY=pts/1 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/sbin/service sshd start
/var/log/auth.log:Sep 12 11:26:40 bos-lpwy9 sudo: rabdelaz : TTY=pts/1 ; PWD=/home/rabdelaz/workspace/automation ; USER=root ; COMMAND=/usr/sbin/service ssh start
/var/log/auth.log:Sep 12 11:55:29 bos-lpwy9 sudo: rabdelaz : TTY=pts/0 ; PWD=/home/rabdelaz/workspace ; USER=root ; COMMAND=/bin/grep -i ssh /var/log/auth.log /var/log/boot.log /var/log/centrifydc-install.log /var/log/centrify_mapper_error.log /var/log/daemon.log /var/log/dpkg.log /var/log/faillog /var/log/fontconfig.log /var/log/jockey.log /var/log/kern.log /var/log/lastlog /var/log/lpr.log /var/log/mail.log /var/log/pm-powersave.log /var/log/pycentral.log /var/log/syslog /var/log/ufw.log /var/log/user.log /var/log/Xorg.0.log
/var/log/dpkg.log:2013-09-11 13:36:18 install libnet-ssh-perl <none> 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:18 status half-installed libnet-ssh-perl 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:18 status half-installed libnet-ssh-perl 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:18 status unpacked libnet-ssh-perl 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:18 status unpacked libnet-ssh-perl 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:24 configure libnet-ssh-perl 0.09-1 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:24 status unpacked libnet-ssh-perl 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:24 status half-configured libnet-ssh-perl 0.09-1
/var/log/dpkg.log:2013-09-11 13:36:24 status installed libnet-ssh-perl 0.09-1
答案1
好的,由于某种原因,您的ssh
服务无法启动。日志中应该有一些信息,请尝试
sudo grep -i ssh /var/log/*log
然后发布输出,我们看一下。
不过,我猜只需重新安装ssh
服务器即可解决问题。如果您不介意丢失对ssh
配置所做的任何更改,请尝试以下操作:
sudo apt-get purge openssh-server ssh
sudo apt-get install openssh-server ssh
sudo service ssh start
然后尝试从另一台机器再次登录。