SSH 비밀번호 인증 완료
여기에 언급 된대로 ssh 클라이언트가 암호 프롬프트에 액세스하지 못하도록하는 방법을 찾고 있습니다.
password:
루트 로그인 프롬프트 를 할 수 없습니다 . sshd_config
읽을 파일을 변경했습니다 .
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
권한 chmod 700 ~/.ssh
및 chmod 600 ~/.ssh/authorized_keys
. 내가 무엇을 놓치고 있습니까? 암호가 필요합니까?
상세 정보 :
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Next authentication method: password
/ etc / ssh / sshd_config :
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# 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 no
에 /etc/ssh/sshd_config
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication no
두 번째 줄의 주석 처리를 제거하고 필요한 경우 예를 아니요로 변경합니다.
그런 다음 실행
service ssh restart
운영
service ssh restart
대신에
/etc/init.d/ssh restart
이 작동 할 수 있습니다.
이 작업을 자동으로 수행하는 펼쳐집니다.
# only allow key based logins
sed -n 'H;${x;s/\#PasswordAuthentication yes/PasswordAuthentication no/;p;}' /etc/ssh/sshd_config > tmp_sshd_config
cat tmp_sshd_config > /etc/ssh/sshd_config
rm tmp_sshd_config
다음 단계를 따랐습니다 (Mac의 경우).
에 /etc/ssh/sshd_config
직원 변경
#ChallengeResponseAuthentication yes #PasswordAuthentication yes
에
ChallengeResponseAuthentication no PasswordAuthentication no
이제 rsa 키 생성 : ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
(저를 위해 rsa 키가 작동했습니다. dsa 키가 작동하지 않습니다).
키 ~/.ssh/id_rsa
와 함께 생성됩니다.~/.ssh/id_rsa.pub
이제 .ssh 폴더로 이동하십시오. cd ~/.ssh
입력하십시오 rm -rf authorized_keys
(때때로 여러 키로 인해 오류가 발생 함).
시작하다 vi authorized_keys
:wq
이 빈 파일을 저장하려면 입력 하십시오.
시작하다 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
SSH 다시 시작
sudo launchctl stop com.openssh.sshd sudo launchctl start com.openssh.sshd
이것은 내가 가진 튜토리얼에서 가져온 것입니다.
컴퓨터에서 루트로 :
ssh-keygen -t rsa
암호를 비워 둡니다.
로컬 컴퓨터에서 : (비밀번호를 입력해야합니다)
ssh root@remotemachine mkdir -p .ssh
그때:
cat .ssh/id_rsa.pub | ssh root@remotemachine 'cat >> .ssh/authorized_keys'
이제 pw 프롬프트없이 로그인 할 수 있습니다.
ssh root@remotemachine
링크 : http://www.linuxproblem.org/art_9.html 문제가 있으면!
참고 URL : https://stackoverflow.com/questions/20898384/ssh-disable-password-authentication
'IT' 카테고리의 다른 글
모범 사례 : 속성에서 예외 발생 (0) | 2020.08.16 |
---|---|
JavaScript에서 모듈로 연산자 (%)를 어떻게 사용할 수 있습니까? (0) | 2020.08.16 |
최종 블록이 제대로 채워지지 않은 경우 (0) | 2020.08.16 |
Angular CLI를 최신 버전으로 업그레이드하는 방법 (0) | 2020.08.15 |
FastMM에 의해 특정 메모리 블록이 해제되지 갑자기는지 프로그래밍 방식으로 알 수있는 방법이 있습니까? (0) | 2020.08.15 |