SSH without password (shared home folder)

6,797

Solution 1

You only have one user. So it's not a multiple users problem. Make sure the .ssh directory has mode 700.

However, you're doing it wrong anyway. You should create different users for each developer and put them in a common group. If they need to work on the same files, you make them writable by their common group and put them in a directory that has the "set group ID" flag set, so whatever they write to it will belong to the group.

Solution 2

Since he asked, he must have his reasons. Here are some ideas:

  1. Make sure that your public key string is not wrapped. It should be on one continuous line in authorized_keys.
  2. Permissions should be rw-r-r (644) for authorized_keys.
  3. Check permissions for ~/.ssh. Should be rwx-- (700).
  4. Also make sure that /etc/ssh/sshd_config contains "PubkeyAuthentication yes".

Solution 3

Password-less SSH login:

  • generate a private/public key pair without a passphrase and put the public key in your authorized_keys file:

    ssh-keygen -t dsa -N ""
    cd .ssh/
    cat id_dsa.pub >> authorized_keys
    

Authorized_keys protection:

  • authorized_keys file must only be readable by the user and the user's home directory can only be writable by the user:

    chmod go-rwx authorized_keys
    chmod go-w ~/
    

Solution 4

In my experience, ssh is very particular about file and directory permissions. The authorized_keys file must be 'rw-r--r--' and the .ssh directory that contains it must also be accessible by everyone (but not writeable by world) This means the .ssh dictory, and the full directory path leading to it.

When you don't get this right, the key-exchange logins fail.

Mike

Share:
6,797
Vladaimir Cetkovic
Author by

Vladaimir Cetkovic

Java developer who has a passion for Agile/Scrum development. Also has Data warehouse experience using the Oracle stack of tools.

Updated on September 18, 2022

Comments

  • Vladaimir Cetkovic
    Vladaimir Cetkovic over 1 year

    I have a question about passwordless ssh with one home folder.

    I have created a common /home/developers account, and multiple users (developerA,developerB ...). All developers have been delegated the same home folder (/home/developers).

    As developerA on his machine, I have done the following:

    1. ssh-keygen -t rsa -f developerA -C [email protected]
    2. (on server). added the .pub to the server /home/developers/.ssh/authorized_keys file
    3. ssh developerA@myServer -i developerA

    I am thinking that the problem is linked to permissions, because the authorized_keys file is owned by developers (-rw------- 1 developers developers 2033 Nov 11 22:55 authorized_keys )

    Does anyone have a solution to this problem, or how to go about multiple-user passwordless ssh without creating a home folder for each of them.

    Thanks in advance guys

    • TomMD
      TomMD over 11 years
      Shouldn't that be ssh developers@myServer -i developerA. If not, then you should flesh out the question a bit more.
  • Admin
    Admin over 11 years
    Nope. That's wrong and SSH will complain if the key is readable by anyone else other than the user that owns it.
  • Admin
    Admin over 11 years
    @unbeli Nope. Here's my ~/.ssh: -rw------- 1 realnc users 223 Feb 28 2011 authorized_keys. Works like a charm.
  • Admin
    Admin over 11 years
    Maybe its a question of which sshd server your using. I've used openssh and it has required the world-readable attribute. Weird you have different experience.
  • Admin
    Admin over 11 years
    this unfortunately didn't work
  • TomMD
    TomMD over 11 years
    You two are talking about different files (authorized keys vs the users key in his .ssh directory)
  • frankster
    frankster over 10 years
    It would be helpful if you went into some more detail about the problems you allude to.