From bc1e1f23542b2f4934b02fedc7fd063eb24b8d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Sun, 27 Feb 2022 21:41:27 +0300 Subject: [PATCH] TIL: Using private key to login to homeless user --- ssh/using-private-key-to-login-to-homeless-user.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ssh/using-private-key-to-login-to-homeless-user.md diff --git a/ssh/using-private-key-to-login-to-homeless-user.md b/ssh/using-private-key-to-login-to-homeless-user.md new file mode 100644 index 0000000..12efc04 --- /dev/null +++ b/ssh/using-private-key-to-login-to-homeless-user.md @@ -0,0 +1,10 @@ +Authorized keys for the users stays in the home directory of the user by default. But not every user have home directory. If you want to use your keys to login as a user which does not have home directory, you can do this: + +Assuming the name of the user is `git`: +- create `/etc/ssh/authorized_keys_git` and put your key there +- add the following in `/etc/ssh/sshd_config`: +```bash +Match User git + AuthorizedKeysFile /etc/ssh/authorized_keys_%u +``` +and restart sshd.