1. Create user, -m
means create no home dir.
useradd -M <username>
2. Create ssh-key, -C
is specifying the comment.
ssh-keygen -t rsa -b 4096 -C "<comment>"
3. Download private key
and put it in .ssh
folder on client side.
4. Move public key
to /etc/ssh/authorized_keys/
.
5. Set permission.
chown <username> /etc/ssh/authorized_keys/<username>.pub
chmod 644 /etc/ssh/authorized_keys/<username>.pub
6. Edit sshd_config
vim /etc/ssh/sshd_config
------------------------
Match User <username>
AuthorizedKeysFile /etc/ssh/authorized_keys/<username>.pub
due to complication permission thing only use the etc folder