SSH - 在公钥认证期间要求密码输入

时间:2014-02-13 17:59:38

标签: authentication ubuntu ssh public-key-encryption

我已经阅读了一些关于公钥认证的内容,但我认为我错过了一个关键方面。

我有一个Ubuntu服务器,我已经配置为Subversion服务器,它使用非标准端口通过SSH接受SVN连接。所以,要结账,它会像:

svn co svn+ssh://user@example.com:12345/repos/public

现在,我的服务器目前支持基于密码的身份验证和公钥身份验证。假设我办公室的服务器已经用螺栓固定,防火墙和所有服务器都正常工作,我不必担心有人从服务器上复制文件。

对于我的两台客户端笔记本电脑,我已经生成了公钥 - 私钥对,并通过ssh-copy-id命令将客户端的公钥添加到服务器上的AuthorizedKeys列表中。我现在可以从这些客户端笔记本电脑SSH连接到服务器而无需密码。

但这让我很担心。如果有人闯入我的酒店房间偷了我的笔记本电脑,那么他们就可以拉硬盘,将~/.ssh的内容复制到另一台机器上,并尝试毫不费力地登录我的服务器。如果我只是使用基于密码的身份验证,只记住密码或将它们存储在加密的TrueCrypt存档中,那么它会更加安全。

我知道在客户端创建密钥对时,必须输入密码。是否可以要求服务器不仅要验证公钥,还要求输入密码?如果需要的只是窃取单个员工的笔记本电脑并从中复制文件以获得全面的系统访问权限,这似乎是一个非常弱的系统。

谢谢。

2 个答案:

答案 0 :(得分:1)

您可以使用额外的密码来保护客户端上的密钥库,因此需要解锁密钥才能使用它,但这是在客户端上配置的,服务器无法强制执行。使用SSH-agent,您只需要解锁一次密钥,只要客户端正在使用就可以使用它。

答案 1 :(得分:0)

这在另一个SO网站上有所涉及。

https://serverfault.com/questions/93807/how-do-i-setup-ssh-with-both-private-key-and-password

以下是SSHD服务器脚本示例。

#######################################################
###  Calomel.org  SERVER  /etc/ssh/sshd_config
#######################################################
#
Port 22
Protocol 2
AddressFamily inet
#ListenAddress 127.0.0.1

#See the questions section for setting up the gatekeeper
#ForceCommand /tools/ssh_gatekeeper.sh 

AllowUsers calomel@10.10.10.3 calomel@192.168.*
AllowGroups calomel

AllowTcpForwarding yes
#AuthorizedKeysFile .ssh/authorized_keys (need to be be commented for OpenSSH 5.4)
Banner /etc/banner
ChallengeResponseAuthentication no
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
ClientAliveInterval 15
ClientAliveCountMax 3
Compression yes
GatewayPorts no
LogLevel VERBOSE
LoginGraceTime 50s
MACs hmac-sha2-512-96,hmac-sha2-512,hmac-sha2-256-96,hmac-sha2-256,hmac-sha1-96,hmac-sha1
MaxAuthTries 6
MaxStartups 10
PasswordAuthentication yes
PermitEmptyPasswords no
#PermitOpen localhost:80
PermitRootLogin no
PermitUserEnvironment no
PidFile /var/run/sshd.pid
PrintLastLog yes
PrintMotd no
PubkeyAuthentication yes
StrictModes yes
Subsystem sftp /usr/libexec/sftp-server
SyslogFacility AUTH
TCPKeepAlive no
UseDNS no
UseLogin no
UsePrivilegeSeparation yes
X11DisplayOffset 10
X11Forwarding no
X11UseLocalhost yes

#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       ForceCommand cvs server
#
#######################################################
###  Calomel.org  SERVER  /etc/ssh/sshd_config
#######################################################
相关问题