Adding SSH key to user without shell

Found this via google but lost link

<clips>

I figured out a workaround for this (for all you kids googling this issue out there) but I doubt it is secure, but I am running it for testing scripts from PHP in a virtual environment so that doesn’t matter to me.

Since the APACHE user’s home is “/var/www” and ssh-keygen requires access to /var/www/.ssh but cannot create it because there is no shell you can do the following.

mkdir /var/www/.ssh

chown -R apache:nobody /var/www/.ssh

sudo -u apache ssh-keygen -t rsa

For ssh-keygen just press enter if you want to test otherwise fill in some values to secure your stuff!

sudo -u apache ssh-copy-id -i /var/www/.ssh/whatever.pub root@host

And you are done!

<claps>

Remember that if user has no $HOME like nobody has, $HOME will be / and .ssh is expected to be there!!!!

Found from here

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.