ssh 无法连接(tcp连接可以建立,但是接着就死掉)

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
raymond1984
帖子: 3
注册时间: 2009-04-09 18:34

ssh 无法连接(tcp连接可以建立,但是接着就死掉)

#1

帖子 raymond1984 » 2009-04-09 18:52

先说一下我的情况:
一台笔记本,假如是A,一台IBM台式机,假如B
A:ubuntu 8.10,安装了desktop,sshd正常启动
B:ubuntu 8.10,没有安装desktop,sshd正常启动

A可以ssh到自己上,使用密码验证或者key验证都没有问题
B可以ssh到自己上,使用密码验证或者key验证都没有问题

但是当A试着ssh到B上的时候, 出现
Disconnecting: Bad packet length 1349676916.
网络上说这是由于sshclient和ssh server的protocol版本不一样,可是无已经将B上的sshd──config修改为只使用2,可是还是会出现这个问题,为什么呢?

第二个问题更奇怪,
如果使用B 去ssh到A,则输入
ssh user@A之后就长时间不响应,这时候查看A的网络
tcp 0 0 **cqu:49919 B:telnet ESTABLISHED
tcp 0 0 **cqu:59933 hk-in-f83.google.co:www ESTABLISHED
tcp 0 0 **cqu:ssh B:47476 ESTABLISHED
可以看到B和A之间的连接已经建立,可是这个时候B就没有任何响应了,直到超时,然后提示
connection was closed by ..
这个是为什么呢?
谢谢各位达人赐教。

下面是我的配置文件,B的配置跟A一样的

A的ssh_config
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_dsa
Port 22
Protocol 2
# Cipher 3des
# Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no


A的sshd_config文件

# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
ListenAddress 0.0.0.0
#Protocol 2 #commented by shiquan
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes
UseDNS no
raymond1984
帖子: 3
注册时间: 2009-04-09 18:34

Re: ssh 无法连接(tcp连接可以建立,但是接着就死掉)

#2

帖子 raymond1984 » 2009-04-09 18:55

机器上没有手动安装任何防火墙,ufw被禁用,我现在也纳闷,是不是ubuntu默认安装并启动了什么访问限制?我在A的/etc/hosts.allow中添加了
sshd: B: allow
也没有用
raymond1984
帖子: 3
注册时间: 2009-04-09 18:34

Re: ssh 无法连接(tcp连接可以建立,但是接着就死掉)

#3

帖子 raymond1984 » 2009-04-10 14:01

我知道为什么了,我在校园网,使用linux下的DRCOM登录上网,但是在/etc/drcom.conf配置文件中没有将本地局域网设为except,所以,本地局域网的包全部被发到代理服务器了。
天哪,这个问题折腾了好久阿,当时配置drcom的时候觉得这一项现在还用不到,可以以后配置,结果浪费了这么长的时间,真是郁闷。
回复