![]() |
Stuck on SSH public key authentication for www-data
I have a web server and a desktop. I would like to be able to mount /var/www/html/ from the webserver to a directory on my desktop using sshfs.
I have a user 'anthony' on both the server and the desktop. I can SSH between the desktop and server with public key authentication (password login is disabled). From there, I can 'su' to www-data (I have set a password for the www-data user). Code:
anthony@maples-desktop:~$ ssh 192.168.0.100 I thought that I could just copy my id_rsa.pub from my desktop into /var/www/.ssh/authorized_keys on the server. But it's not working like I thought it would: Code:
ssh www-data@192.168.0.100 Code:
$ ssh www-data@192.168.0.100 -v I've checked, and I'm using the correct home directory for www-data: Code:
www-data@poweredge1950:/home/anthony$ cd I didn't know if I needed a keypair for www-data, so I generated that, and that didn't fix it either. I checked that the permissions for authorized_keys is the same as the user 'anthony': Code:
www-data@poweredge1950:~$ cd .ssh/ |
/var/www/.ssh/authorized_keys permissions should be set to owner rw (chmod 600 /var/www/.ssh/authorized_keys)
|
Quote:
|
authorized_keys file contains anthony@maples-desktop's id_rsa.pub content?
|
Quote:
Code:
www-data@poweredge1950:~$ md5sum .ssh/authorized_keys |
Quote:
At this point, you don't see differences comparing ~/.ssh directories for both www-data and anthony users ? Not using authorized_keys2 in anthony's .ssh for example? |
Nope, nothing like that:
Code:
www-data@poweredge1950:~$ ls .ssh/ Code:
anthony@maples-desktop:~$ ls .ssh/ |
Nothing in logs (as root) tail /var/log/messages
Or grep ssh /var/log/* |
What are the permissions of /var/www ?
|
Code:
www-data@poweredge1950:~$ ls -la /var/www/ Code:
root@poweredge1950:~# tail /var/log/messages However, I checked the end of auth.log, which contained something worth mentioning (immediately after I tried SSHing to www-data@192.168.0.100): Code:
root@poweredge1950:~# tail /var/log/auth.log |
Quote:
Try chmod 755 /var/www |
www-data has a nologin shell, I'll bet is jamming you up.
Code:
grep www-data /etc/passwd |
Quote:
I wonder why it refuses to let you login when group has write permission? Thanks for all the help! :D |
Quote:
Code:
root@poweredge1950:~# grep www-data /etc/passwd |
Quote:
Also, the user and group www-data are for privilege separation and should not have write access to anything in the web server's document root, except for special exceptions regarding individual files in certain CMSs. Adding write permission for www-data, as shown in #10 above, breaks the security model and is likely end up costing you in the medium to long term. What problem were you trying to solve? If it was shared access to the web server's document root or other files, then a special group should be made for that and write access given to that new group instead of www-data. |
All times are GMT -5. The time now is 03:51 PM. |