Linux 사용자는 로그인할 수 없습니다.

Linux 사용자는 로그인할 수 없습니다.

루트 자격 증명을 사용하는 명령을 사용하여 새 사용자를 생성 하려고 하면 useradd올바르게 생성되지만 새로 생성된 사용자와 해당 자격 증명으로 PuTTY 콘솔을 사용하여 로그인하면 사용자 이름을 입력할 수 있지만 비밀번호를 제공하면 멈춤 PuTTY 창 세션 시간이 초과되어 창이 닫힐 때까지 시간이 오래 걸립니다. 그러나 루트 자격 증명을 사용하면 빠르게 세션에 들어갑니다.

AllowUsers파일을 확인해 보았지만 /etc/ssh/sshd_config일치하는 항목을 찾지 못했기 때문에 AllowUsers temipuser제가 만든 사용자 이름이 어디에 있는지 수동으로 추가해 보았습니다. temipuser다른 PuTTY 콘솔에서 변경한 후 이 사용자 이름을 다시 입력하려고 시도했지만 다시 동일했습니다. 왜 이런 일이 일어나는지 전혀 모르겠습니다.

또 다른 문제는 파일의 항목에 사용자(예를 들어)를 추가하면 temipuser루트 사용자가 계속 액세스할 수 있는지 여부입니다. 나는 여기서 일을 엉망으로 만들고 싶지 않습니다. 내가 아는 한, 지정된 사용자만 허용되고 다른 사용자는 거부됩니다.AllowUserssshd_configAllowUsers

답변1

/var/log/secure또는 아래에서 관련 항목을 찾으세요 /var/log/auth.log. 또한 /etc/security/access.conf사용자 서버에 액세스할 수 있는 사용자 지정 규칙을 추가하지 않도록 하세요 .

이러한 로그에는 실패한 로그인에 대한 정보가 포함되어 있으며 무엇이 잘못되었는지 명확하게 나타낼 수 있습니다.

/etc/security/access.conf파일은 로그인을 허용하거나 거부하는 (사용자/그룹, 호스트), (사용자/그룹, 네트워크/넷마스크) 또는 (사용자/그룹, tty) 조합을 지정합니다.

답변2

다음으로 Linux 시스템에 사용자를 추가한 후 해당 사용자에 대한 키도 생성해야 합니다(프로토콜 유형 2, RSA 권장). Putty의 키 생성기를 사용하여 지침을 찾을 수 있습니다.여기.

퍼티 키 생성기의 "authorized_keys 파일에 붙여넣기 위한 공개 키" 상자에서 모든 텍스트를 선택하고 텍스트 편집기에 붙여넣은 후 이름으로 저장합니다 authorized_keys.

Linux 시스템의 새 사용자 홈 디렉터리에 .ssh디렉터리가 없으면 만듭니다. 이 디렉터리는 사용자가 소유해야 하며 해당 사용자만 액세스 권한을 가집니다. ( chmod 700 .ssh) authorized_keys파일을 이 디렉터리에 복사합니다. 파일에 대한 권한 변경을 사용 chmod 0600하고 소유권을 사용자로 변경해야 합니다.

이제 사용자가 로그인할 수 있습니다.

답변3

이 명령을 시도하기 전에 루트이거나 sudo를 사용하여 명령을 실행해야 합니다.

파일을 변경할 때마다/etc/ssh/sshd_config, SSH 서비스를 다시 시작해야 합니다. 명령은 다음과 같습니다:

systemctl restart  sshd.service

비밀번호를 사용하여 SSH로 로그인하려는 새 사용자는 해당 사용자를 추가해야 합니다.사용자 허용각 사용자의 구분 기호로 공백을 사용하십시오.

Eg:
AllowUsers root testUser

루트 사용자가 SSH를 통해 로그인할 수 있도록 하려면 다음을 확인해야 합니다.루트 사용자 로그인 허용, 그 값은 다음과 같아야합니다파일에/etc/ssh/sshd_config

예를 들어: 아래 sshd_config 파일을 확인하세요. 이 구성을 사용하면 SSH를 사용하여 로그인할 수도 있습니다.테스트 사용자그리고뿌리사용자:

#       $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/bin:/bin:/usr/sbin:/sbin

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

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

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
#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)
ChallengeResponseAuthentication 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 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/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

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

답변4

adduser temipuser대신 테스트 하시나요 useradd temipuser ? ? ?

sshd_conf의 Linux 매뉴얼에는 다음과 같이 나와 있습니다.

사용자 허용

    This keyword can be followed by a list of user name patterns, separated by 
spaces. If specified, login is allowed only for user names that match one of the 
patterns. Only user names are valid; a numerical user ID is not recognized. **By 
default, login is allowed for all users.** If the pattern takes the form USER@HOST 
then USER and HOST are separately checked, restricting logins to particular users 
from particular hosts. The allow/deny directives are processed in the following 
order: DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups.

따라서 AllowUsers를 추가할 필요가 없습니다. 이 옵션을 추가하면 원격 루트 로그인을 방지할 수 없을 것 같습니다(활성화하는 경우).루트 사용자 로그인 허용

관련 정보