LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2028|回复: 3

请教大侠ssh外网无法访问问题!

[复制链接]
发表于 2007-10-5 19:30:38 | 显示全部楼层 |阅读模式
debian 4.0,只装了基本系统,在apt-get install openssh-server后,在局域网的192.168.1.*的几台机器可以用ssh客户端连到debian,但外网的10.*的机器用ssh客户端却连不上。几个主要配置文件如下:

/* ssh_config */
Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
    PasswordAuthentication yes
#   HostbasedAuthentication 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,1
#   Cipher 3des
#   Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

/* sshd_config */
# 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
# 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 no
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


/* hosts.allow */
sshd: 10.  192.168.1.

/* hosts.deny */


我在宿舍的路由器上做了端口映射了,把路由器的端口22映射为debian机器的ssh服务
记得以前debian 3.1时是可以的,不过过了2年,不知道是怎么回事?
请大侠赐教!!!!
发表于 2007-10-5 19:39:27 | 显示全部楼层
试试把
hosts.allow 中关于sshd的注释掉,然后从外网访问,然后用tcpdump抓包看看,进来的IP是什么?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-5 20:05:57 | 显示全部楼层
Post by springwind426
试试把
hosts.allow 中关于sshd的注释掉,然后从外网访问,然后用tcpdump抓包看看,进来的IP是什么?


我试了,从外网连接,tcpdump根本没有反映,奇怪啊。
我在局域网内连接,可以抓到包的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-5 21:12:52 | 显示全部楼层
Post by darling1111
我试了,从外网连接,tcpdump根本没有反映,奇怪啊。
我在局域网内连接,可以抓到包的。



解决了,我换了个端口就行了,可能是22被其他机器占用了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表