-1

I am a newbie to linux administration.

I have a box with centos 6.5 x64.

Ive been configuring ssh access via public/private key.

Ive been wondering if I could add the public key to a user group instead of a user (in the /home/username directory).

All users who can ssh will be under a specific group, which will have the public key.

If not, how should I proceed for new users created to have the public key automatically?

Thanks

Yash
  • 133
  • 6

2 Answers2

2

sshd normally reads authorized public keys from a file named .ssh/authorized_keys in each user's home directory. Each user would normally have their own copy of this file and would normally maintain it themselves.

The name of this authorized_keys file can be specified in the sshd_config file through the AuthorizedKeysFile directive. The default value of this directive is:

AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

You can use Match group to add another file to this list:

Match group special
    AuthorizedKeysFile /etc/ssh/special_key .ssh/authorized_keys .ssh/authorized_keys2

Match sections like this should go at the end of sshd_config. The match rule applies to all directives following the match until the next match or until the end of the file.

Kenster
  • 2,082
  • 16
  • 15
1

You could add this to the /etc/skel directory which is used as a template for newly created users.

If you want this for only a specific set of users, create an additional skel dir and use this during user creation.

Sven
  • 97,248
  • 13
  • 177
  • 225