I found one article where the mentioned about public key - AUTHORIZED KEY location in ubuntu linux system
AUTHORIZED KEY LOCATION
When a user tries to log in using key-based authentication, the OpenSSH server looks for authorized keys from a directory specifies in the server configuration using the AuthorizedKeysFile option. The default is .ssh/authorized_keys in the user's home directory.
However, having the authorized keys stored in the user's home directory means that the user can add new keys that authorize logins to his/her account. This is convenient, but the user can then give these keys to friends or colleagues, or even sell them for Bitcoins (this has actually happened). SSH keys are furthermore permanent and remain valid until expressly removed.
If authorized keys are added for root or service accounts, they easily remain valid even after the person who installed them has left the organization. They are also a convenient way for hackers to establish permanent presence on a system if there is no detection and alerts about unauthorized new keys.
For these reasons, most larger organizations want to move authorized keys to a root-owned location and established a controlled provisioning and termination process for them.
I wants to Move SSH key to root Owned Location
Following is standard solution.
MOVING SSH KEYS TO A ROOT-OWNED LOCATION
In principle, moving SSH keys to a root-owned location is easy:
- Create a suitable root-owned directory, e.g., /etc/ssh/keys, under which authorized keys are stored.
- Create a subdirectory under this directory for each user, and move each user's authorized_keys file to /etc/ssh/keys//authorized_keys.
- Finally, change set AuthorizedKeysFile /etc/ssh/keys/%u/authorized_keys in /etc/ssh/sshd_config.
My question is, in Ubuntu Linux 16.04 EC2 instance
- if we specify authorized_key location at root level, then does ~/.ssh/authorized_keys will still work ?
- Will I able to ssh connect with my ec2 instance ?