Linux에서 Mac으로 SSH - 권한이 거부되었습니다.

Linux에서 Mac으로 SSH - 권한이 거부되었습니다.

Windows 7 호스트에서 Oracle Linux VM을 실행하고 SSH를 통해 MacBook에 연결하려고 합니다.

Mac에서 개인/공개 키를 만들었습니다. 내용을 폴더의 파일에 복사했습니다 id_rsa.pub. 현재 사용자의 권한을 으로 변경했습니다. 및 에 대한 권한이 으로 변경되었습니다.authorized_keys.sshauthorized_keys600~~/.ssh700

또한 다음 명령을 사용하여 Oracle Linux VM의 내용을 id_rsa.pubauthorized_keys 파일에 복사했습니다.

ssh-copy-id

또한 Mac에는 Windows 머신의 Oracle Linux VM에서 완벽하게 SSH로 연결할 수 있는 Oracle Linux VM이 있습니다.

그러나 다음 명령만으로는 Mac에 SSH로 연결할 수 없습니다.ssh macdomain

SSH를 성공적으로 수행하려면 다음을 사용해야 합니다 ssh username@macdomain . 사용자 이름이 없으면 비밀번호를 묻는 메시지가 표시되며 최종 결과는 다음과 같습니다.

Permission denied (publickey, keyboard-interactive)

이것은 내 sshd_config 파일입니다.

#   $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus 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 change a
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

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

#RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys
AllowUsers username
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords both PasswordAuthentication and
# ChallengeResponseAuthentication must be set to "no".
#PasswordAuthentication no
#PermitEmptyPasswords no

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

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

# 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'.
# Also, PAM will deny null passwords by default.  If you need to allow
# null passwords, add the " nullok" option to the end of the
# securityserver.so line in /etc/pam.d/sshd.
#UsePAM yes

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

# pass locale information
AcceptEnv LANG LC_*

# no default banner path
#Banner none

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

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

# XAuthLocation added by XQuartz (http://xquartz.macosforge.org)
XAuthLocation /opt/X11/bin/xauth

나는 거의 모든 관련 주제를 검색하고 살펴 보았지만 소용이 없었습니다.

답변1

VM의 사용자 이름은 Mac의 사용자 이름과 다릅니다. 기본적으로 ssh사용자 이름은 명시적으로 지정하지 않으면 동일한 것으로 간주됩니다. 존재하지 않는(또는 아직 설정하지 않은) 사용자로 로그인을 시도하고 있기 때문에 항상 실패합니다.

이를 방지하려면 매번 사용자 이름을 지정하거나.ssh/config문서가상 머신에서는 다음과 같습니다.

Host mac
    Hostname macdomain
    User yourmacusername

이는 해당 호스트의 기본 사용자 이름만 재정의합니다. 원하는 경우 ssh mac호스트 이름을 생략 할 수도 있습니다.

관련 정보