2016-03-07 54 views
2

我希望能够使用密码连接到root @ localhost,并且只能使用私钥连接到外部(root @ my-ip)。我没有找到在/ etc/ssh/sshd_config中写什么来允许这个...如果它需要一个SSH密钥和一个密码,那也可以。SSH:只接受来自本地主机的密码连接

你有什么想法吗?

回答

2

这取决于你openssh的版本,但在最近的,你可以设置:

PermitRootLogin prohibit-password 
Match LocalAddress 127.0.0.1,::1 # localhost 
    PermitRootLogin yes 

或者使用由您的版本(PasswordAuthentication)支持的其他一些等价的。

+1

它适用于:Match LocalAddress 127.0.0.1,:: 1 :-)谢谢。 –

+0

感谢关于IPv6的说明。我总是忘记:) – Jakuje