登录我的 ssh 服务器时遇到问题

登录我的 ssh 服务器时遇到问题

问这个问题我感觉自己很蠢,但我已经研究这个问题好几天了(断断续续),但还是搞不清。我刚刚在我的计算机上安装了 lubuntu,我可以使用 localhost 和密码验证在本地 ssh 上进行操作,并且可以从其他两台计算机顺利 ping 它。我尝试从其中任何一台计算机 ssh,但仍然无法使用我的密码进行验证。

我已经重新安装了 openssh-server 几次,但似乎就是无法弄清楚。

有人对可能出现的问题有什么建议吗?

新信息:

我已经创建了一个新用户,只是为了确保它与用户无关,并且新用户也无法登录。

以下是 ssh -vv cusername@fable 的输出:

ssh -vv cusername@fable
OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to fable [192.168.1.76] port 22.
debug1: Connection established.
debug1: identity file /home/susername/.ssh/identity type -1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /home/susername/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/susername/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version 1.00
debug1: no match: 1.00
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7
debug2: fd 4 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa
debug2: kex_parse_kexinit: aes128-cbc
debug2: kex_parse_kexinit: aes128-cbc
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug2: dh_gen_key: priv key bits set: 132/256
debug2: bits set: 506/1024
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'fable' is known and matches the RSA host key.
debug1: Found key in /home/susername/.ssh/known_hosts:3
debug2: bits set: 528/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/susername/.ssh/identity ((nil))
debug2: key: /home/susername/.ssh/id_rsa (0x219e2358)
debug2: key: /home/susername/.ssh/id_dsa ((nil))
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/susername/.ssh/identity
debug1: Offering public key: /home/susername/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/susername/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
cusername@fable's password: 
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
cusername@fable's password: 
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
cusername@fable's password: 
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,password).

这是我的 iptables:

sudo iptables -L
[sudo] password for susername: 
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination    

这是我从远程机器到相关服务器的 nmap:nmap -P0 192.168.1.76

Starting Nmap 5.00 ( http://nmap.org ) at 2012-07-24 23:32 CDT
Interesting ports on fable (192.168.1.76):
Not shown: 997 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
80/tcp  open  http
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 1.58 seconds

猫/etc/ssh/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

# 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

# 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

然后我将 sshd_config.factory-default 复制回 sshd_config 并遇到同样的问题,它不接受我的密码。

更新:

我放弃了。这似乎是 lubuntu 的问题,但可能是我操作不当。我最终在那里安装了 linux-mint,一切都运行正常。谁知道呢……不过我真的很喜欢 linux-mint!

答案1

从你的日志中我可以看出,防火墙和某些东西都没有问题hosts.deny——否则你就不会遇到密码提示。但让我们分析一下你的日志输出。

首先,您的身份文件似乎需要替换:

debug1: identity file /home/susername/.ssh/identity type -1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug2: key_type_from_name: unknown key type '-----END'

这是一个 ASCII 封装的导出密钥——ssh 需要原始二进制密钥。但似乎您还有另外两个有效的私钥文件:

debug1: identity file /home/susername/.ssh/id_rsa type 1
debug1: identity file /home/susername/.ssh/id_dsa type -1

此外,远程主机验证成功:

debug1: Host 'fable' is known and matches the RSA host key.
debug1: ssh_rsa_verify: signature correct

接下来,您的私钥文件中只有一个是有效的:

debug2: key: /home/susername/.ssh/identity ((nil))
debug2: key: /home/susername/.ssh/id_rsa (0x219e2358)
debug2: key: /home/susername/.ssh/id_dsa ((nil))

我已经展示了第一个问题。此外,我们看到服务器不接受任何密钥——因此协商会退回到交互式密码提示:

debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/susername/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password

最后:

cusername@fable's password: 
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: No more authentication methods to try.
Permission denied (publickey,password).

看起来您也提供了错误的密码。

概括:

两个无效私钥无法使用,第三个私钥不被服务器接受 —— 这会将您带回到交互式密码提示。您的密码不被接受。您确定为远程主机上的指定用户提供了正确的密码吗?可能的错误如下:

  • 提供的密码属于不同的用户
  • 用户和密码可能在本地主机上匹配 - 但在远程主机上,该用户具有不同的密码
  • 远程主机上不存在该用户

编辑:

如果使用用户名/密码登录仍然失败,尽管您确定提供了正确的密码,那么最好检查/var/log/auth.log您尝试登录的机器。此日志文件应该会为您提供有关出错的更多详细信息(所有登录尝试以及 sudo 尝试都记录在那里)。

相关内容