Hi,

I am unable to connect via SSH without password (ssh-copy-id was launched) to a 
VM running Debian Stable. 

After some investigations, it is most likely a permission issue

May  1 15:32:42 vm sshd[131848]: debug1: trying public key file 
/home/user/.ssh/authorized_keys
May  1 15:32:42 vm sshd[131848]: debug1: fd 5 clearing O_NONBLOCK
May  1 15:32:42 vm sshd[131848]: Authentication refused: bad ownership or modes 
for directory /home/user

On this system (not installed by me), my user has an UID and GID of 0 in 
/etc/passwd. Several users share root privileges like this on the server.

After a ssh connexion (it is working with password authentification) done as 
'user'

        $ ssh user@server
        user@server's password: ....

I am directly connected as root

        root@server:~# whoami
        root
        root@server:~# su user
        root@server:~# whoami
        root

.ssh files of user directory are owned by root

# ls -la /home/user/.ssh/
total 4
drwx------ 2 root user  29  1 mai   15:38 .
drwxr-xr-x 3 1001 user 106 11 févr. 11:10 ..
-rw------- 1 root user 395  1 mai   15:38 authorized_keys

I tried to change the owner of the file authorized_keys (I guess if it matches 
the user used in ssh connexion command, it will allow the ssh connexion by 
keys) but chown fails silently.

        root@server:~# chown user /home/user/.ssh/authorized_keys 
        root@server:~# ls -la /home/user/.ssh/authorized_keys 
        -rw------- 1 root user 395  1 mai   15:38 .ssh/authorized_keys

I tried a `chattr -i` on the file, unsuccessfully. 

If I launch again ssh-copy-id with root@server instead of user@server, I can 
connect without password. But I would prefer to connect with my user.

What is my best move here?



Reply via email to