each time i delete this file: /home/user/.ssh/authorized_keys , someone creates it again.

i deleted the file and checked if the user has ssh access or not, but i am sure he hasn't.

how can i disable the creation of these keys?

Is there a way that the user can create keys?
What about sftp? Does they use sftp to login?

i am using Centos 6 with Cpanel.

  • the problem is i find a lot of keys under: /home/xxx/.ssh/authorized_keys xxx = users on cpanel Mar 29, 2015 at 12:42

2 Answers 2


If you'd like to prevent users from being able to log into a system via public key auth, you can set PubkeyAuthentication to 'no' in your sshd.conf (typically in /etc/ssh/sshd_config). Alternately you can set AuthorizedKeysFile to '/dev/null' to simply prevent sshd from looking at their file. This will probably be more effective than trying to prevent users from writing a file in their home directory.

  • 1
    Note that setting AuthorizedKeysFile to /dev/null works but will result in the following confusing warning: User [username] authorized keys /dev/null is not a regular file Mar 28 at 14:53

You can change the location of the authoized_keys file by editing sshd_config and setting the new location with the AuthorizedKeysFile keyword. However, It is inadvisable to completely disable public key authentication, which is what you would effectively do if you made it impossible to find an authorized_key file for any user, so you may consider some other options:

AllowUsers allows login only for specified users.

AllowGroups allows login only for the specified groups.

DenyUsers disallows login only for specified users.

DenyGroups disallows login only for specified groups.

More information on the sshd_config file is available by running man sshd_config.

Not the answer you're looking for? Browse other questions tagged or ask your own question.