How to copy authorized_keys to another user on linux?

6,018

Your permissions are too lax.

chmod u=rwx,go= .ssh    # 0700
chmod u=rw,go= .ssh/*   # 0600

I'm going to assume that the user/group you have specified are the correct values for whatever uses /home/web as its home directory.

To diagnose this kind of error it's best to look at the daemon/auth logs on the server. See the tag here for more details.

Share:
6,018

Related videos on Youtube

blented
Author by

blented

Updated on September 18, 2022

Comments

  • blented
    blented over 1 year

    I can ssh into a Linux node on the cloud with root. I've created another user, web, and I want to add my ssh keys to that user. Here's what I've tried so far (as root):

    mkdir -p /home/web/.ssh
    cp ~/.ssh/authorized_keys /home/web/.ssh/authorized_keys
    chown web /home/web/.ssh
    chgrp web /home/web/.ssh
    chown -R :web /home/web/.ssh
    chmod -R g+w /home/web/.ssh
    find /home/web/.ssh -type d -exec chmod g+s '{}' \;
    systemctl reload sshd
    

    I'm pretty sure I'm over-setting the permissions but regardless I still can't ssh into the server as the web user. Box is Fedora 21 on Digital Ocean.

    What am I missing?

  • blented
    blented about 9 years
    As root I set the permissions for /home/web/.ssh and /home/web/.ssh/* as you suggested. My /var/log/daemon.log and /var/log/auth.log are both non-existant, and ssh -vvv doesn't seem to be a valid option or run anything. I've read through the info here: unix.stackexchange.com/tags/ssh/info and tried everything listed as well but still can't ssh in as web. Any further ideas?
  • roaima
    roaima about 9 years
    For Fedora the security logs are apparently in /var/log/secure. Take a look to see why ssh is objecting to your login attempt.