0

LAN の外部からホーム サーバーを ssh する際に問題が発生しています。

私の知る限り、ルーターに VPN クライアントをインストールしたときに問題が発生した可能性があります。でも、以前はこうだったのかもしれません。よくわかりません。

キーペアを介して検証するようにセットアップしたので、常にパスワードを入力する必要はありませんでしたが、パートナーがサーバーにアクセスできるようにパスワードアクセスも許可されました。

LAN 経由のログイン (ユーザー名の難読化)

$ ssh -v user@192.168.1.1
OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type 1
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: identity file /Users/user/.ssh/id_dsa type -1
debug1: identity file /Users/user/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: DSA 3e:6e:35:b3:05:14:39:bb:6f:a6:29:4e:a3:a8:59:81
debug1: Host '192.168.1.1' is known and matches the DSA host key.
debug1: Found key in /Users/user/.ssh/known_hosts:1
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/user/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.1.1 ([192.168.1.1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_AU.UTF-8
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-49-generic x86_64)user

ドメイン名でログインします (ドメイン名、ユーザー名、および IP アドレスは難読化されていますが、正しいものです)。-p フラグの使用に注意してください...これは、すべてのトラフィックがルーター上の VPN 経由で送信されるため、実行する必要があります。VPN サービスは、指定されたポートのポート フォワーディングを許可します。

$ssh -v -p nnnnn user@my.domain.com
OpenSSH_6.2p2, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.domain.com [xxx.xxx.xxx.xxx] port nnnnn.
debug1: Connection established.
debug1: identity file /usr/home/user/.ssh/id_rsa type 1
debug1: identity file /usr/home/user/.ssh/id_rsa-cert type -1
debug1: identity file /usr/home/user/.ssh/id_dsa type -1
debug1: identity file /usr/home/user/.ssh/id_dsa-cert type -1
debug1: identity file /usr/home/user/.ssh/id_ecdsa type -1
debug1: identity file /usr/home/user/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version dropbear_2013.58
debug1: no match: dropbear_2013.58
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA 46:4c:2f:53:72:75:da:d8:e4:fc:d4:55:86:90:6a:3c
debug1: checking without port identifier
The authenticity of host '[my.domain.com]:nnnnn ([xxx.xxx.xxx.xxx]:nnnnn)' can't be established.
RSA key fingerprint is 46:4c:2f:53:72:75:da:d8:e4:fc:d4:55:86:90:6a:3c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[my.domain.com]:nnnnn,[xxx.xxx.xxx.xxx]:nnnnn' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /usr/home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /usr/home/user/.ssh/id_dsa
debug1: Trying private key: /usr/home/user/.ssh/id_ecdsa
debug1: Next authentication method: password
user@my.domain.com's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
user@my.domain.com's password:

これが私のsshd_configファイルです:

# 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 を介してドメインに接続できます (開発者の Web サイトは正常に表示されます) が、ポート 22 を使用するため、LAN の外部から git または sftp を使用できないことは明らかです。

ありがとう。

4

1 に答える 1

0

私はそれを解決しました-ルーターのVPNがそれを壊しています. もちろん、それはまだ LAN 上で動作していました。なぜなら、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

そのため、ドメイン名もポートも解決できませんでした。

私がしなければならなかったこと:

  1. AirVPN サイトにアクセスし、ランダム ポート フォワードを設定して、その出口ポートを 22 に設定します。
  2. ルーターでポート転送しないでください。
  3. NAT がポート 22 をコンピューターにルーティングするように iptables をセットアップします。

    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 PREROUTING -i tun11 -p tcp --dport 22 -j DNAT --to-destination xx.xx.xx.xx

    iptables -t nat -I PREROUTING -i tun11 -p udp --dport 22 -j DNAT --to-destination xx.xx.xx.xx

于 2013-07-27T23:48:33.200 に答える