![升级到 22.04.1 后,ssh 登录仅在本地网络上有效。当我尝试离开本地网络时,总是出现“权限被拒绝”](https://linux22.com/image/1029113/%E5%8D%87%E7%BA%A7%E5%88%B0%2022.04.1%20%E5%90%8E%EF%BC%8Cssh%20%E7%99%BB%E5%BD%95%E4%BB%85%E5%9C%A8%E6%9C%AC%E5%9C%B0%E7%BD%91%E7%BB%9C%E4%B8%8A%E6%9C%89%E6%95%88%E3%80%82%E5%BD%93%E6%88%91%E5%B0%9D%E8%AF%95%E7%A6%BB%E5%BC%80%E6%9C%AC%E5%9C%B0%E7%BD%91%E7%BB%9C%E6%97%B6%EF%BC%8C%E6%80%BB%E6%98%AF%E5%87%BA%E7%8E%B0%E2%80%9C%E6%9D%83%E9%99%90%E8%A2%AB%E6%8B%92%E7%BB%9D%E2%80%9D.png)
一切都运行良好(ssh),直到我最终决定从 20.04.1 升级,因为我厌倦了每次登录服务器时都看到“do-upgrade”消息。因此,升级后,我能够通过本地网络(家庭)登录无头服务器,直到今天仍然如此,但当我尝试从办公室(离家)登录时,我总是被拒绝权限(公钥、密码),就像我的密码不好一样,但我使用与在家登录时相同的密码。我在服务器上插入了一个显示器,启用了远程 ssh 连接和远程桌面共享,但仍然无法在离家时使用。此时,我在谷歌上搜索了大约 3-4 天,弄乱了 sshd_config,试图查看新的 Ubuntu/openssh 是否以某种方式阻止了来自家庭网络之外的 IP(UFW 已禁用,是的,我的路由器设置为将端口 22 转发到我的服务器,就像升级到 22.04.1 之前一样)。我尝试清除 openssh-server,重新安装它,但它仍然只能在我的本地网络上工作。希望有人能为这个烦人的问题带来一些“新鲜空气”。
dux@MacBook-Pro-de-duX ~ % ssh -vvv [email protected]*.***.**
OpenSSH_9.0p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/dux/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include
/etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug2: resolve_canonicalize: hostname 184.14*.***.** is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' ->
'/Users/dux/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' ->
'/Users/dux/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve;
disabling
debug3: ssh_connect_direct: entering
debug1: Connecting to 184.14*.***.*** [184.144.***.**] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
debug1: identity file /Users/dux/.ssh/id_rsa type 0
debug1: identity file /Users/dux/.ssh/id_rsa-cert type -1
debug1: identity file /Users/dux/.ssh/id_ecdsa type -1
debug1: identity file /Users/dux/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/dux/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/dux/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/dux/.ssh/id_ed25519 type -1
debug1: identity file /Users/dux/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/dux/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/dux/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/dux/.ssh/id_xmss type -1
debug1: identity file /Users/dux/.ssh/id_xmss-cert type -1
debug1: identity file /Users/dux/.ssh/id_dsa type -1
debug1: identity file /Users/dux/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: Remote protocol version 2.0, remote software version
dropbear_2018.76
debug1: compat_banner: no match: dropbear_2018.76
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 184.14*.***.**:22 as 'dux'
debug3: record_hostkey: found key type RSA in file
/Users/dux/.ssh/known_hosts:1
debug3: load_hostkeys_file: loaded 1 keys from 184.14*.***.**
debug1: load_hostkeys: fopen /Users/dux/.ssh/known_hosts2: No
such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such
file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such
file or directory
debug3: order_hostkeyalgs: prefer hostkeyalgs: rsa-sha2-512-cert-
[email protected],[email protected],rsa-sha2-
512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: sntrup761x25519-
[email protected],curve25519-sha256,curve25519-
[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-
sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-
hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-
hellman-group14-sha256,ext-info-c
debug2: host key algorithms: rsa-sha2-512-cert-
[email protected],[email protected],rsa-sha2-
512,rsa-sha2-256,ssh-rsa,[email protected],ecdsa-
[email protected],ecdsa-sha2-nistp384-cert-
[email protected],[email protected],ssh-
ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-
nistp521
debug2: ciphers ctos: [email protected],aes128-
ctr,aes192-ctr,aes256-ctr,[email protected],aes256-
[email protected]
debug2: ciphers stoc: [email protected],aes128-
ctr,aes192-ctr,aes256-ctr,[email protected],aes256-
[email protected]
debug2: MACs ctos: [email protected],umac-128-
[email protected],[email protected],hmac-sha2-512-
[email protected],[email protected],umac-
[email protected],[email protected],hmac-sha2-256,hmac-sha2-
512,hmac-sha1
debug2: MACs stoc: [email protected],umac-128-
[email protected],[email protected],hmac-sha2-512-
[email protected],[email protected],umac-
[email protected],[email protected],hmac-sha2-256,hmac-sha2-
512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-
[email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-
sha2-nistp256,diffie-hellman-group14-
sha256,[email protected]
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes128-ctr,aes256-ctr,aes128-cbc,aes256-
cbc,3des-ctr,3des-cbc
debug2: ciphers stoc: aes128-ctr,aes256-ctr,aes128-cbc,aes256-
cbc,3des-ctr,3des-cbc
debug2: MACs ctos: hmac-sha2-256
debug2: MACs stoc: hmac-sha2-256
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256
compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256
compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa
SHA256:uGq/Tt6huITf4zqqV3SIIxd8MH1QGcQtahSYGCskpxg
debug3: record_hostkey: found key type RSA in file
/Users/dux/.ssh/known_hosts:1
debug3: load_hostkeys_file: loaded 1 keys from 184.14*.***.**
debug1: load_hostkeys: fopen /Users/dux/.ssh/known_hosts2: No
such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such
file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such
file or directory.
debug1: Host '184.144.***.**' is known and matches the RSA host
key.
debug1: Found key in /Users/dux/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: ssh_set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS.
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: ssh_set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent
contains no identities
debug1: Will attempt key: /Users/dux/.ssh/id_rsa RSA
SHA256:NDtstCom+vwC4hyw9UQIy6HOiS5lM9tqfs9mO5hTz58
debug1: Will attempt key: /Users/dux/.ssh/id_ecdsa
debug1: Will attempt key: /Users/dux/.ssh/id_ecdsa_sk
debug1: Will attempt key: /Users/dux/.ssh/id_ed25519
debug1: Will attempt key: /Users/dux/.ssh/id_ed25519_sk
debug1: Will attempt key: /Users/dux/.ssh/id_xmss
debug1: Will attempt key: /Users/dux/.ssh/id_dsa
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/dux/.ssh/id_rsa RSA
SHA256:NDtstCom+vwC4hyw9UQIy6HOiS5lM9tqfs9mO5hTz58
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/dux/.ssh/id_ecdsa
debug3: no such identity: /Users/dux/.ssh/id_ecdsa: No such file
or directory
debug1: Trying private key: /Users/dux/.ssh/id_ecdsa_sk.
debug3: no such identity: /Users/dux/.ssh/id_ecdsa_sk: No such
file or directory
debug1: Trying private key: /Users/dux/.ssh/id_ed25519
debug3: no such identity: /Users/dux/.ssh/id_ed25519: No such
file or directory
debug1: Trying private key: /Users/dux/.ssh/id_ed25519_sk
debug3: no such identity: /Users/dux/.ssh/id_ed25519_sk: No such
file or directory
debug1: Trying private key: /Users/dux/.ssh/id_xmss
debug3: no such identity: /Users/dux/.ssh/id_xmss: No such file
or directory
debug1: Trying private key: /Users/dux/.ssh/id_dsa
debug3: no such identity: /Users/dux/.ssh/id_dsa: No such file or
directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]*.***.**'s password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email protected]*.***.**'s password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email protected]*.***.**'s password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected].***.**: Permission denied (publickey,password).
dux@MacBook-Pro-de-duX ~ %