SSH 未检测身份验证方法

SSH 未检测身份验证方法

因此,基本上,我正在尝试为服务器的一部分创建一个 SFTP 帐户,该帐户不需要 SSH-Key 或 googles-2fa-pam 模块。我的 /etc/ssh/sshd_config 文件中有以下设置:

Match User sharex
    PubkeyAuthentication no
    PasswordAuthentication yes
    AuthenticationMethods password
    PermitTunnel no
    AllowAgentForwarding no
    AllowTcpForwarding no
    X11Forwarding no
    ForceCommand internal-sftp
    ChrootDirectory /home/sharex

这是我的 /etc/pam.d/sshd 文件的底部:

# Standard Un*x password updating.
@include common-password
auth required pam_google_authenticator.so nullok

运行“service ssh status”时出现错误:

● ssh.service - OpenBSD Secure Shell server
 Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-01-19 11:22:25 CET; 52min ago
  Process: 20132 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 20143 (sshd)
    Tasks: 1 (limit: 4583)
   CGroup: /system.slice/ssh.service
       └─20143 /usr/sbin/sshd -D

Jan 19 11:22:25 mango systemd[1]: Starting OpenBSD Secure Shell server...
Jan 19 11:22:25 mango sshd[20132]: Disabled method "password" in 
AuthenticationMethods list "publickey,password"
Jan 19 11:22:25 mango sshd[20143]: Disabled method "password" in AuthenticationMethods list "publickey,password"
Jan 19 11:22:25 mango sshd[20143]: Server listening on 0.0.0.0 port XXX.
Jan 19 11:22:25 mango sshd[20143]: Server listening on :: port XXX.
Jan 19 11:22:25 mango systemd[1]: Started OpenBSD Secure Shell server.
Jan 19 11:22:44 mango sshd[20224]: error: Disabled method "password" in AuthenticationMethods list "publickey,password"
Jan 19 11:22:46 mango sshd[20224]: Failed password for sharex from 127.0.0.1 port 56442 ssh2
Jan 19 11:22:47 mango sshd[20224]: Connection closed by authenticating user sharex 127.0.0.1 port 56442 [preauth]

当我尝试通过 ssh 登录帐户时:

Permission denied, please try again.

ssh -v 的输出:

root@mango ~ # ssh -v sharex@localhost -p XXX OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n 7 Dec 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to localhost [127.0.0.1] port XXX. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubunt u-4ubuntu0.1 debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.1 pat OpenSSH* compat 0x04000000 debug1: Authenticating to localhost:XXX as 'sharex' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit > compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit > compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Lj/m0+cUQjvYHaXu57qYTtTeg878 c6KgQxk03AhOcUw debug1: Host '[localhost]:XXX' is known and matches the ECDSA host key. debug1: Found key in /root/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rs a-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: password debug1: Next authentication method: password sharex@localhost's password: debug1: Authentications that can continue: password Permission denied, please try again.

有谁能帮助我或尝试给我指明正确的方向,因为我不知道我能做什么。如果您需要更多信息(例如配置文件),请在下面回复 :) 谢谢!

答案1

在 /etc/ssh/sshd_config 或 ssh_config 中的 UsePAM yes 后添加此项

AuthenticationMethods publickey,keyboard-interactive

相关内容