Friday, February 12, 2010

Login to FreeNAS via Passwordless SSH - GNU/Linux

I found this solution on the FreeNAS forums. It's not very straightforward, in my opinion, to setup SSH passwordless login on FreeNAS.

Taken from FreeNAS forums:

What you need to do to customize your server for passwordless authentication:
  1. From WebGUI|Advanced|Execute command or shell
    1. protect the /mnt directory by setting the mode to 755(we don't want users to write on /mnt, that can fill up the RAM disk and crash the system.

      You must change the mod as startup command, after each reboot.

      Code:

      chmod 755 /mnt
    2. For your safety change the mode for each mount, or at least one "mount".

      Code:

      chmod 755 /mnt/mount
    3. Create the user(A) home directory /mnt/mount/userA

      Code:

      mkdir /mnt/mount/userAdir
    4. Make userA the owner of his home directory

      Code:

      chown userA /mnt/mount/userAdir
    5. Secure userA home directory

      Code:

      chmod 700 /mnt/mount/userAdir
  2. Set userA home directory on WebGUI|Access|Users|Edit|Home directory to point to /mnt/mount/userAdir

  3. From your remote client(ssh/PuTTy)
    1. Check if home directory is set corectly for userA. The output should be /mnt/mount/userAdir

      Code:

      ssh -p 22 userA@FreeNASip 'pwd'
    2. Create the .ssh directory

      Code:

      ssh -p 22 userA@FreeNASip 'mkdir .ssh'
    3. Upload your id_rsa.pub or id_dsa.pub to remote .ssh directory.

      Code:

      cat id_rsa.pub | ssh -p 22 userA@FreeNASip 'cat >> .ssh/authorized_keys'
    4. Change the .ssh dir mode

      Code:

      ssh -p 22 userA@FreeNASip 'chmod -R 700 ~/.ssh'
  4. Now try to login passwordless.

2 comments:

  1. Step C-3 needs to be "cat id_rsa.pub | ssh -p 22 userA@FreeNASip 'cat >> ~/.ssh/authorized_keys'

    at least that's what worked for me. Thanks for the post helped a bunch!!

    ReplyDelete