我正在尝试为我在数字海洋ubuntu 12.04服务器上用Chef创建的用户帐户设置ssh访问。我在数字海洋中设置了选项,以便在创建Droplet时自动复制Mac的ssh密钥。
我可以毫无问题地以root用户身份登录,但其他用户无法通过身份验证。这似乎是一个常见问题,我检查了其他一些答案,并找到此命令以获取更多信息:
ssh -vvv -i id_rsa user@serverIP
使用该命令的root用户(成功)的日志为
调试
1: Offering RSA public key: /Users/evan/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp snip!
debug3: sign_and_send_pubkey: snip!
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
失败的用户:
调试
1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/evan/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/evan/.ssh/id_dsa
debug3: no such identity: /Users/evan/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
在我看来,这意味着公钥不正确。但是,如果我以root用户身份登录并转到home/otheraccount/.ssh/authorized_keys
,则可以看到我的ssh密钥在那里。我以为也许有错误,所以我做到了,cp .ssh/authorized_keys ~/home/otheraccout/.ssh/authorized_keys
但是那没有帮助。我不知道还能去哪里。
我的etc/ssh/sshd_conig
:
# 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
"sshd_config" 88L, 2508C
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
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
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
# GS
SAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM no
Banner /etc/ssh_banner
编辑:
drwx------ 2 deploy deploy 4096 Apr 20 06:00 .ssh
-rw------- 1 deploy deploy 820 Apr 20 05:35 authorized_keys
编辑2:
如评论中所建议/var/log/authlog
:
Apr 21 04:59:30 localhost sshd[586]: User deploy not allowed because account is locked
Apr 21 04:59:30 localhost sshd[586]: input_userauth_request: invalid user deploy [preauth]
我试着做sudo usermod --expiredate -1 deploy
,它回来了no changes
drwx------ 2 deploy deploy 4096 Apr 20 06:00 .ssh
-rw------- 1 deploy deploy 820 Apr 20 05:35 authorized_keys
serverIP
(/var/log/auth.log
)中的日志行是deploy
什么?
passwd -u
。可以像deploy
现在这样使用,但是真的很好奇为什么我的厨师部署会创建锁定的用户。请复制/粘贴您在上面的评论作为答案,以便我给您功劳
~/home/otheraccount/.ssh
应该具有700
并且~/home/otheraccount/.ssh/authorized_keys
应该具有600
许可权,并且两个文件都应归于otheraccount