ssh 连接期间无法使用密码登录

ssh 连接期间无法使用密码登录

/etc/ssh/ssh_config的如下

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

#Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
    PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
#    SendEnv LANG LC_*
#    HashKnownHosts yes
#    GSSAPIAuthentication yes

我的student用户

ubuntu@ubuntu:~$ finger student
Login: student                  Name: 
Directory: /home/student                Shell: /bin/bash
Never logged in.
No mail.
No Plan.

当与我的虚拟机建立 SSH 连接时,它应该要求我输入密码,但事实并非如此,我得到了这个?

joseph@joseph-X541UJ:~$ multipass list 
Name                    State             IPv4             Image
ubuntu                  Running           10.226.208.153   Ubuntu 18.04 LTS
joseph@joseph-X541UJ:~$ ssh [email protected]
[email protected]: Permission denied (publickey).

为什么我无法使用学生密码登录,请帮忙

答案1

您需要在服务器端进行设置。如果您根本无法连接到服务器来进行这些更改,那么远程执行此操作可能不太顺利。

不过,请先尝试强制密码验证:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no student@<ip-address>

一旦您成功通过 SSH 连接,您就可以更改服务器端设置。

我建议先备份配置:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults

现在,编辑配置文件:

sudo nano /etc/ssh/sshd_config

找到说明的行PasswordAuthentication并将其设置为yes

PasswordAuthentication yes

保存文件并重新启动 SSH

sudo systemctl restart ssh

本指南有关 ssh 配置的更多信息。

相关内容