Como restringir o login da raiz do SSH, mas permitir algumas exceções

1

no openssh, você pode restringir o login root (PermitRootLogin não), mas ele pode ter uma exceção?

    
por Vladimir Franciz S. Blando 29.05.2012 / 14:05

1 resposta

5

Dado que o login como root não é uma boa idéia, dê uma olhada no manpage do sshd:

PermitRootLogin

Specifies whether root can log in using ssh(1). The argument must be ''yes'', ''without-password'', ''forced-commands-only'' or ''no''. The default is ''yes''.

If this option is set to ''without-password'' password authenti- cation is disabled for root.

If this option is set to ''forced-commands-only'' root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). All other authentication methods are disabled for root.

If this option is set to ''no'' root is not allowed to log in.

Portanto, você pode usar PermitRootLogin without-password para permitir a autenticação de chave pública / privada enquanto não permite a autenticação de senha; ou talvez PermitRootLogin forced-commands-only para permitir que você faça login como root, mas sem acesso interativo.

O último caso requer que você edite o arquivo authorized_keys , para especificar qual comando está habilitado para que o registro seja usuário, assim:

command="rdiff-backup --server" ssh-rsa AAAAB3NzaC1y... (rest of key)

ou melhor ainda, permita o login root somente com comandos forçados a partir de um endereço IP específico:

from="10.1.1.1",command="/home/user/command/to/execute" ssh-rsa AAAAB3NzaC1y... (rest of key)
    
por 29.05.2012 / 15:27