Ubuntu 23.10 密码SSH远程服务器提示Permission denied问题求助
Ubuntu 23.10 密码SSH远程服务器提示Permission denied问题求助
大家好,我目前在用Ubuntu 23.10,想要SSH连接一台不在我管控范围内的服务器,对方已经给了我用户名和密码。原本计划先用密码登录进去,再配置密钥认证,但现在连密码登录都一直失败,折腾了好几个办法都没解决,想请各位帮忙分析下问题出在哪。
我做的操作步骤大概是这样的:
- 先生成了密钥对(因为后续要配置密钥认证)
- 安装openssh-server:
sudo apt install openssh-server - 尝试启动sshd服务时,报错
Failed to start sshd.service: Unit sshd.service not found.,按照网上用户的建议,先查了SSH相关的服务列表:
之后改用systemctl -l --type service --all|grep sshsudo systemctl start ssh成功启动了服务。
接下来我尝试连接服务器:
ssh -vvv MYUSERNAME@HOSTADDRESS
但一直收到权限拒绝的错误,debug日志如下:
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.
我翻了不少论坛帖子,大部分都是关于公钥认证的问题,但我现在是密码登录失败。我也修改了本地的/etc/ssh/sshd_config部分配置,修改后的内容如下:
# This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value. Include /etc/ssh/sshd_config.d/*.conf # Port and ListenAddress options are not used when sshd is socket-activated, # which is now the default in Ubuntu. See sshd_config(5) and # /usr/share/doc/openssh-server/README.Debian.gz for details. #Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_ecdsa_key #HostKey /etc/ssh/ssh_host_ed25519_key # Ciphers and keying #RekeyLimit default none # Logging SyslogFacility AUTH LogLevel DEBUG # Authentication: #LoginGraceTime 2m #PermitRootLogin prohibit-password #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #PubkeyAuthentication yes # Expect .ssh/authorized_keys2 to be disregarded by default in future. #AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 #AuthorizedPrincipalsFile none #AuthorizedKeysCommand none #AuthorizedKeysCommandUser nobody # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # HostbasedAuthentication #IgnoreUserKnownHosts no # Don't read the user's ~/.rhosts and ~/.shosts files #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) KbdInteractiveAuthentication no # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes #GSSAPIStrictAcceptorCheck yes #GSSAPIKeyExchange no # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the KbdInteractiveAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via KbdInteractiveAuthentication may bypass # the setting of "PermitRootLogin prohibit-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and KbdInteractiveAuthentication to 'no'. UsePAM yes #AllowAgentForwarding yes #AllowTcpForwarding yes #GatewayPorts no X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes #PermitTTY yes PrintMotd no #PrintLastLog yes #TCPKeepAlive yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #UseDNS no #PidFile /run/sshd.pid #MaxStartups 10:30:100 #PermitTunnel no #ChrootDirectory none #VersionAddendum none # no default banner path #Banner none # Allow client to pass locale environment variables AcceptEnv LANG LC_* # override default of no subsystems Subsystem sftp /usr/lib/openssh/sftp-server
麻烦各位帮忙看看问题可能出在哪,提前谢谢大家了!祝大家一天愉快~
备注:内容来源于stack exchange,提问作者davy36
相关产品推荐
相关产品推荐

