DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-11-28 09:14:36

rtg20
Member
Registered: 2007-12-23
Posts: 34

OpenSSH (fun_plug 0.5) - connect with public key

Hi, I can't get this to work. I created a public key on the client computer and copied it over to /mnt/HD_a2/home/root/.ssh/authorized_keys ; I set the permissions on this file to rw by root and nothing else...it still doesn't work.

I'm really frustrated. I did a search on this forum and found a thread pertaining to DropBear, but not OpenSSH.

please help!

Thanks,

Richard

Offline

 

#2 2008-11-28 10:16:09

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: OpenSSH (fun_plug 0.5) - connect with public key

rtg20 wrote:

/mnt/HD_a2/home/root/.ssh/authorized_keys

Why did you copy it there? Did you also check permissions of the .ssh dir?

Offline

 

#3 2008-11-28 18:01:39

rtg20
Member
Registered: 2007-12-23
Posts: 34

Re: OpenSSH (fun_plug 0.5) - connect with public key

thanks for the reply. I copied it there because i thought that was the right place....? Where should it be...?

I checked the permissions, the files are owned by root and authorized_keys is 600. The directory .ssh is 755.

thanks,

Richard

Offline

 

#4 2008-11-28 18:05:23

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: OpenSSH (fun_plug 0.5) - connect with public key

rtg20 wrote:

thanks for the reply. I copied it there because i thought that was the right place....? Where should it be...?

In root's home directory, and that's not /mnt/HD_a2/home/root by default, but /home/root.
Permissions of ~/.ssh should be 700.

Offline

 

#5 2008-11-28 18:10:10

rtg20
Member
Registered: 2007-12-23
Posts: 34

Re: OpenSSH (fun_plug 0.5) - connect with public key

thanks for the reply. if as root i do cd and then pwd I get /mnt/HD_a2/home/root and not /home/root ... also in /etc/passwd the dir for root is /mnt/HD_a2/home/root ... so maybe it's just differet on my system...?

anyway, I moved the file like you said and fixed the permissions, and it still doesn't work!

thanks,

Richard

Offline

 

#6 2008-11-28 18:56:29

rtg20
Member
Registered: 2007-12-23
Posts: 34

Re: OpenSSH (fun_plug 0.5) - connect with public key

ok I think I fixed it!

my key is still in /mnt/HD_a2/home/root

not sure exactly what I did...but I was trying to get this to work for an scp script and now it does! Maybe chmod 640 for authorized_keys as in

http://linuxproblem.org/art_9.html

...?

anyway, thanks for the help!

Offline

 

#7 2008-11-30 18:57:16

mastervol
Member
Registered: 2008-09-06
Posts: 81

Re: OpenSSH (fun_plug 0.5) - connect with public key

here is what i did:

1) login with the account, which should have a key
2) ssh-keygen -t dsa -f username.identity
3) create in users home (/home/username): .ssh (chmod 600)
4) cat the public key to authorized_keys (chmod 600)
5) move the key to .ssh
6) restart service (not rellay necessary)
7) open the key in putty-gen, save it as .pkk

Last edited by mastervol (2008-12-24 09:46:17)


DNS-323     F/W: 1.06  H/W: ??  ffp: 0.5  Drives (normal mode): 1 x 1,5 TB Seagate SATA II ST31500341AS, 1 x 250 GB Western Digital SATA I

Offline

 

#8 2008-12-14 08:29:57

seeheng
Member
Registered: 2007-12-03
Posts: 8

Re: OpenSSH (fun_plug 0.5) - connect with public key

I can also confirm that Fonz's steps worked for me.

I am using two DNS323, one shadows the other using RSYNC.

However I face a problem where the /home/root/.ssh folders that contain the keys disappear after reboot, despite the fact that I had issue store-passwd.sh.

Any ideas?

Offline

 

#9 2008-12-14 10:44:33

mastervol
Member
Registered: 2008-09-06
Posts: 81

Re: OpenSSH (fun_plug 0.5) - connect with public key

/home/root is on the read only part (flash memory), right?
if i am not mistaken, store-passwd.sh does only store the /etc/oasswd and /etc/group file .


DNS-323     F/W: 1.06  H/W: ??  ffp: 0.5  Drives (normal mode): 1 x 1,5 TB Seagate SATA II ST31500341AS, 1 x 250 GB Western Digital SATA I

Offline

 

#10 2008-12-14 11:38:14

seeheng
Member
Registered: 2007-12-03
Posts: 8

Re: OpenSSH (fun_plug 0.5) - connect with public key

In that case I will just modify the fun_plug.init script to link the key files from /mnt/HD_a2.

Thanks

mastervol wrote:

/home/root is on the read only part (flash memory), right?
if i am not mistaken, store-passwd.sh does only store the /etc/oasswd and /etc/group file .

Offline

 

#11 2008-12-24 09:59:17

mastervol
Member
Registered: 2008-09-06
Posts: 81

Re: OpenSSH (fun_plug 0.5) - connect with public key

since i like to keep everything where it is i am using the following .sh:

can be done with root:

Code:

#! /ffp/bin/bash

date

userid="myuser"
myreturn=$(cat /etc/passwd | grep $userid)
myreturn1=$(echo $myreturn | cut -f1 -d :)
#echo $myreturn1
if [ "$myreturn1" != "$userid" ]
    then 
    echo userid: $userid not found
    echo adding user $userid
    useradd -d /home/$userid -m $userid
    mkdir /home/$userid/.ssh
    chmod 700 /home/$userid/.ssh
    chown $userid /home/$userid/.ssh
    echo /opt/bin/wakelan -m 12345678 > /home/$userid/wol.stfu
    chmod 700 /home/$userid/wol.stfu
    chown $userid /home/$userid/wol.stfu
  cp createkeys.sh /home/$userid
    
    else echo userid: $userid found
    #TBD checks for existence of authorized_keys
    
    exit
fi

must be done with "myuser":

Code:

#! /ffp/bin/bash

userid="myuser"
rm $userid.identity.pub
rm $userid.identity
ssh-keygen -t dsa -f $userid.identity -v -N "" 
cat $userid.identity.pub > /home/$userid/.ssh/authorized_keys
chmod 600 /home/$userid/.ssh/authorized_keys
chown $userid /home/$userid/.ssh/authorized_keys

"myuser" hast to login and change the password before it can work.

Last edited by mastervol (2008-12-24 10:04:03)


DNS-323     F/W: 1.06  H/W: ??  ffp: 0.5  Drives (normal mode): 1 x 1,5 TB Seagate SATA II ST31500341AS, 1 x 250 GB Western Digital SATA I

Offline

 

#12 2008-12-30 15:45:34

mastervol
Member
Registered: 2008-09-06
Posts: 81

Re: OpenSSH (fun_plug 0.5) - connect with public key

ok, i updated the script for the user
the logged in user will be used

Code:

#! /ffp/bin/bash

# creates a key for the current user in the home directory
# although, it won't be used, make sure that a password is set for this user, before trying to login via PKI

userid=$(whoami)
rm ~/$userid.identity.pub
rm ~/$userid.identity
ssh-keygen -t dsa -f ~/$userid.identity -v -N "" 

if [ ! -d ~/.ssh ];
then
mkdir ~/.ssh
fi

cat ~/$userid.identity.pub > ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

DNS-323     F/W: 1.06  H/W: ??  ffp: 0.5  Drives (normal mode): 1 x 1,5 TB Seagate SATA II ST31500341AS, 1 x 250 GB Western Digital SATA I

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB