用户 SSH 始终显示与 xxx 的连接已关闭。成功登录 CWP(控制 Web 面板)/ CentOS 7 后

问题描述 投票:0回答:1

我的用户 ssh 有问题,成功登录后与 xxx 的连接突然关闭。但是,root ssh 没有问题。我已经尝试将用户的 shell 访问权限设置为所有选项(sftp/jailkit/full shell),但仍然无法访问用户 ssh。我使用 CentOS 7,CWP pro 版本是 0.9.8.1170,我的一些设置在下面的附件中。

这是我尝试通过 ssh 登录该用户时的终端日志:

root@xxx:~# ssh [email protected] -p 1324
[email protected]'s password:
Last login: Fri Sep 15 21:36:09 2023 from 192.168.1.2
Connection to 192.168.1.202 closed.

这是我的 sshd_config 文件:

#   $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# 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.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 1324
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile  .ssh/authorized_keys

#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
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users 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 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'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

# override default of no subsystems
Subsystem   sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server

这是 /etc/passwd 的文件:

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
centos:x:1000:1000:Centos:/home/centos:/bin/bash
mysql:x:997:995:MySQL server:/var/lib/mysql:/sbin/nologin
saslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologin
dovecot:x:97:97:Dovecot IMAP server:/usr/libexec/dovecot:/sbin/nologin
dovenull:x:995:993:Dovecot's unauthorized user:/usr/libexec/dovecot:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
cwpsrv:x:994:992::/usr/local/cwpsrv:/sbin/nologin
cwpsvc:x:993:991::/usr/local/cwpsrv/var/services:/sbin/nologin
login:x:992:990::/home/login:/sbin/nologin
clamupdate:x:991:989:Clamav database update user:/var/lib/clamav:/sbin/nologin
amavis:x:990:987:User for amavis:/var/spool/amavisd:/sbin/nologin
clamscan:x:989:986:Clamav scanner user:/:/sbin/nologin
vmail:x:101:12:Virtual mailbox:/var/vmail:/sbin/nologin
vacation:x:988:985:Virtual vacation:/var/spool/vacation:/sbin/nologin
opendkim:x:987:984:OpenDKIM Milter:/var/run/opendkim:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
nginx:x:986:983:nginx user:/var/cache/nginx:/sbin/nologin
varnishlog:x:985:982:varnishlog user:/dev/null:/sbin/nologin
varnish:x:984:982:Varnish Cache:/var/lib/varnish:/sbin/nologin
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
mongod:x:983:981:mongod:/var/lib/mongo:/bin/false
tomcat:x:1003:1003::/home/tomcat:/bin/bash
satrio:x:1004:1004::/home/satrio:/sbin/nologin
domain:x:1005:1005::/home/jail/domain/home/domain:/bin/bash

这是我尝试通过 ssh 登录 root 时成功的:

root@xxx:~# ssh [email protected] -p 1324
[email protected]'s password:
Last login: Sat Sep 16 00:13:10 2023 from 192.168.1.2

********************************************
 Welcome to CWP (CentOS WebPanel) server
********************************************

CWP Wiki: http://wiki.centos-webpanel.com
CWP Forum: http://forum.centos-webpanel.com
CWP Support: http://centos-webpanel.com/support-services

 17:02:25 up 2 days, 23:15,  1 user,  load average: 0.08, 0.07, 0.06
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.1.2      17:02    1.00s  0.18s  0.00s sh /root/.bash_cwp

请帮助我解决这个问题,因为我已经尝试了几天但仍然没有找到任何解决方案:'( .

linux centos centos7 cwp centos-web-panel
1个回答
0
投票

我刚刚找到了答案,对于 CWP 用户,您必须从 ssh 创建新帐户(

not from panel
),所以
the new account from panel can't be used for ssh
。但是,如果您想保护/限制您的用户 ssh 帐户访问,您可以从从面板创建的帐户激活监狱套件,并将您想要的用户 ssh 的主目录更改为该监狱目录(以更改每个用户的主目录的位置)。用户已存档
/etc/passwd
)。

© www.soinside.com 2019 - 2024. All rights reserved.