Ubuntu ssh在局域网上工作,但不通过域名

Ubuntu ssh在局域网上工作,但不通过域名,ubuntu,ssh,lan,Ubuntu,Ssh,Lan,我在从局域网外部ssh家庭服务器时遇到问题 据我所知,当我在路由器上安装VPN客户端时,可能出现了这个问题。但以前可能是这样的。我不确定 我将其设置为通过密钥对进行验证,这样我就不必总是键入密码,但也允许密码访问,以便我的合作伙伴可以访问服务器 通过LAN登录(用户名模糊) 这是我的sshd_配置文件: # Package generated configuration file # See the sshd_config(5) manpage for details # What ports

我在从局域网外部ssh家庭服务器时遇到问题

据我所知,当我在路由器上安装VPN客户端时,可能出现了这个问题。但以前可能是这样的。我不确定

我将其设置为通过密钥对进行验证,这样我就不必总是键入密码,但也允许密码访问,以便我的合作伙伴可以访问服务器

通过LAN登录(用户名模糊)

这是我的sshd_配置文件:

# Package generated configuration file
# See the sshd_config(5) 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
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_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
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
Subsystem sftp internal-sftp

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
有人知道这里发生了什么吗

我可以通过端口80连接到域(开发人员网站显示良好),但显然不能从lan外部使用git或sftp,因为它们使用端口22


谢谢。

我已经解决了-路由器上的VPN正在破坏它。当然,它还在局域网上工作,因为nat会帮我解决这个问题

当我从不同的位置测试ssh时,我得到了:

ssh -v user@my.domain.name
OpenSSH_6.2p2, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.domain.name [xx.xx.xx.xx] port 22.
debug1: connect to address xx.xx.xx.xx port 22: Connection timed out
ssh: connect to host my.domain.name port 22: Connection timed out
所以它无法解析域名,也无法解析端口

我必须做的是:

  • 访问AirVPN站点,获得一个随机端口转发设置,并将其出口端口设置为22
  • 不要在路由器上进行端口转发
  • 为NAT设置iptables,以将端口22路由到计算机:

    iptables-I FORWARD-I tun11-p udp-d xx.xx.xx.xx--dport 22-j ACCEPT

    iptables-I FORWARD-I tun11-p tcp-d xx.xx.xx.xx--dport 22-j ACCEPT

    iptables-t nat-I预路由-I tun11-ptcp-dport 22-jdnat-到目的地 xx.xx.xx.xx

    iptables-t nat-I预路由-I tun11-p udp-dport 22-j DNAT-to destination xx.xx.xx


  • 我解决了-路由器上的VPN正在破坏它。当然,它还在局域网上工作,因为nat会帮我解决这个问题。当我从不同的位置测试ssh时,它无法解析域名的位置。对不起,浪费了大家的时间。事实上,这并不能完全解决问题。我通过VPN服务设置端口转发,并将其路由到端口22,因此现在我可以执行ssh-v-p nnnuser@my.domain.com我仍然得到同样的东西。我会更新原来的帖子
    # Package generated configuration file
    # See the sshd_config(5) 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
    # HostKeys for protocol version 2
    HostKey /etc/ssh/ssh_host_rsa_key
    HostKey /etc/ssh/ssh_host_dsa_key
    #HostKey /etc/ssh/ssh_host_ecdsa_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
    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
    Subsystem sftp internal-sftp
    
    # Set this to 'yes' to enable PAM authentication, account processing,
    # and session processing. If this is enabled, PAM authentication will
    # be allowed through the ChallengeResponseAuthentication and
    # PasswordAuthentication.  Depending on your PAM configuration,
    # PAM authentication via ChallengeResponseAuthentication may bypass
    # the setting of "PermitRootLogin without-password".
    # If you just want the PAM account and session checks to run without
    # PAM authentication, then enable this but set PasswordAuthentication
    # and ChallengeResponseAuthentication to 'no'.
    UsePAM yes
    
    ssh -v user@my.domain.name
    OpenSSH_6.2p2, OpenSSL 0.9.8k 25 Mar 2009
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Connecting to my.domain.name [xx.xx.xx.xx] port 22.
    debug1: connect to address xx.xx.xx.xx port 22: Connection timed out
    ssh: connect to host my.domain.name port 22: Connection timed out