maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Troubleshooting (https://talk.maemo.org/forumdisplay.php?f=6)
-   -   dropbear and Bluetooth (https://talk.maemo.org/showthread.php?t=3068)

insert_nick 2006-09-14 18:09

dropbear and Bluetooth
 
Hi, I'd like someone to explain me or point me on some written guide on how to do 2 things, or even one of them would be fine ;)

1) I have dropbear working nice, but I start the connection entering as user, and then input the password I've setted on my 770 with passwd user. I'm using Putty on Windows, so I've generated the keys pair with PuttyGen and I've setted the private one in my Putty -> Connection -> SSH -> Auth. I've copied the public one as authorized_keys under home/user/.ssh/ and I've changed the permissions of the folder and the file. But, when connecting with Putty it says "Server refused our key" and I have to log in using the password. Can someone write how to use those keys as they are supposed to? Is it good to copy the public one into the file authorized_keys under home/user/.ssh ?

3) I have a bluetooth dongle on my PC and it is seen on the 770 (tested with hcitool scan). Could I use dropbear to establish a SSH connection through bluetooth rather than wi-fi? How?

BanditRider 2006-09-14 20:15

1) Try renaming your authorized_keys file to authorized_keys2
Permissions should be 600

3) I don't know but wifi is better.

SeRi@lDiE 2006-09-14 21:04

3) Not Possible.

insert_nick 2006-09-15 20:18

Quote:

Originally Posted by BanditRider
1) Try renaming your authorized_keys file to authorized_keys2
Permissions should be 600

3) I don't know but wifi is better.

Thanks, but renaming to authorized_keys2 doesn't change anything. Btw on the wiki it says to chmod the file to 400.

I'm not totally on the dir where to put the authorized_keys (or authorized_keys2) file: is it good "/home/user/.ssh/" ? Or it should be something under root?

Btw, is it too much bad to use the ssh connection with just the user password, I mean without this keypair thing? It works, but how much secure is it with a not so long alphanumeric user password? If it's enough, I can avoid the key check.

Both of you repliers have noticed that I've written "3" for the second question :) Well, let's put here a number 2:

2) How can I use PSCP (or PSFTP?) to transfer files back and forth between 770 and PC? Should I install something on the 770, or the dropbear server/client package on komputika repository is enough? I've tried from a cmd prompt in Windows XP the following command (the x's stand for something else):
Code:

C:\putty> pscp -pw xxxxxxxxxxxxxx c:\test_file.txt user@192.168.x.x:/home/user/test_file.txt
...and I get the error:
Code:

sh: /usr/lib/sftp-server: not found
Can you see what's wrong?

SeRi@lDiE 2006-09-15 21:11

You are better of with WinSCP is much simpler and the default settings in dropbear should work.

BanditRider 2006-09-15 21:45

The authouized_keys2 file should be in /home/user/.ssh
my .ssh directory is mode 755 owner=user; group=users

All the files in the .ssh folder are mode 600 and owner=user; group=users

Code:

~/.ssh $ ls -la
drwxr-xr-x    2 user    users          0 Aug 24 16:33 .
drwxr-x---  18 user    users          0 Sep 14 12:33 ..
-rw-------    1 user    users        404 Jul  1 18:15 authorized_keys2
-rw-------    1 user    users        887 Jul  1 18:15 id_rsa
-rw-------    1 user    users        226 Jul  1 18:15 id_rsa.pub
-rw-------    1 user    users        395 Aug 24 16:33 known_hosts
~/.ssh $

I haven't used putty (or Windows) for a while but I remember something about an "agent" that handled the keys or passwords for encrypted keys.

The known_hosts file should be created the first time you try to connect to the 770.

I connect to the 770 using: ssh user@192.168.1.103
I've set up my router to assign that IP to the 770 based on it's MAC address so it's always the same.

scp is similar to yours but I don't give the destination filename, just the directory:
scp filename user@192.168.1.103:/media/mmc1
or whatever.

fanoush 2006-09-16 06:54

1) shoud be something trivial (putty keys misconfiguration?)
Code:

~ $ ls -la .ssh/
drwx------    2 user    users        1024 Jul  9 10:01 .
drwxr-x---  21 user    users        1024 Sep  9 20:03 ..
-rw-------    1 user    users        1073 Jul  9 10:01 authorized_keys
-rw-r--r--    1 user    users        445 Jul  9 10:01 known_hosts

3) perrfectly possible, i'm using it with windows XP (widcomm bluetooth stack) over bluetooth too, XP is server with Network Access service enabled, n770 is client, should be possible in the other way too. Check bluetooth networking HOWTO in Maemo wiki for details

my bnep-up script
Code:

#!/bin/sh
# use gainroot to become root and relaunch itself
if [ `id -u` != 0 ] ; then
#if not already root, call itself as root
        sudo gainroot <<EOF
$0 $*
EOF
        exit
fi
# real script follows
BTADDR='00:10:c6:24:05:a9'
IP=192.168.2.2
GW=192.168.2.1
NS=10.6.101.1
IFACE=bnep0

#insmod just to be sure
insmod /mnt/initfs/lib/modules/current/bnep.ko
#start PAN Bluetooth connection
pand --connect $BTADDR

# wait for the interface created by pand
s=60
echo -n "Waiting $s secs for $IFACE"
while [ $s -gt 0 ] ; do
        ifconfig $IFACE >/dev/null 2>&1 && break
        s=$((s-1))
        echo -n "."
        sleep 1
done
echo
if ifconfig $IFACE >/dev/null 2>&1 ; then
# bring it up
echo "OK, bringing $IFACE up"
ifconfig $IFACE $IP up
route add default gw $GW
echo "nameserver $NS" >/tmp/resolv.conf.lo
else
    echo "Error: $IFACE not available."
fi


insert_nick 2006-09-18 17:10

No way, I don't know what I'm doing wrong. This is what I see on n770:
Code:

~ $ ls -la .ssh/
drwx------    2 user    users        0 Sep  18 19:35 .
drwxr-x---  18 user    users        0 Sep  10 22:57 ..
-rw-------    1 user    users        294 Sep  15 20:21 authorized_keys
-rw-r--r--    1 user    users        219 Jul  8 12:54 known_hosts

In Putty -> SSH -> Auth I make it point to the private key file (id_rsa.ppk) and again I have the connection working but it claims that server has refused our key, so it asks for the password and goes on.
I have re-generated the keys with puttygen just to make sure they're good, here they are:

This is the private key that I give to Putty:

Code:

PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc
Comment: rsa-key-20060915
Public-Lines: 4
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of some others scrambled chars...)
Private-Lines: 8
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of some others scrambled chars...)
Private-MAC: (40 scrambled numbers)

...and this is the authorized_keys file in the n770:

Code:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20060915"
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of some others scrambled chars...)
---- END SSH2 PUBLIC KEY ----

:(

BanditRider 2006-09-18 17:20

Did you provide a password when you generated your keys? ( I don't )
If so you'll need to enter that password each time you connect with ssh unless you run the putty agent which will handle that password for you.

insert_nick 2006-09-18 17:25

Quote:

Originally Posted by BanditRider
Did you provide a password when you generated your keys? ( I don't )
If so you'll need to enter that password each time you connect with ssh unless you run the putty agent which will handle that password for you.

Yes I provided a "passphrase", shouldn't I? Ok I'm going to try regenerating without it, thanks.

insert_nick 2006-09-18 17:32

I've just tried loading the agent (pageant), I've added the private key to its list of keys (it asked for the pass phrase too the first time), then now connecting to the n770 it no longer says that the server refuses our keys, just asks for username (user) and password and goes on. Shoult it be how I've described it? If yes, thanks to all and Bandit

BanditRider 2006-09-18 18:55

It shouldn't ask for your username and password if you have the 770's .ssh directory setup right.

You may need to delete the entry in your known_hosts file after you change keys.

insert_nick 2006-09-21 14:33

Quote:

Originally Posted by BanditRider
It shouldn't ask for your username and password if you have the 770's .ssh directory setup right.

You may need to delete the entry in your known_hosts file after you change keys.

I've deleted the known_hosts file, but still it works like described before: I load the agent "pageant" with a saved session named "n770" and private key stored in pageant's keys list, 770's ssh dir has only the authorized_keys file in (with public key), and when I connect it just asks for username and password (no more "server refused our key" error) and gives me access. Is it weird?

BanditRider 2006-09-21 14:53

Check your public key in your authorized_keys file and make sure the key is one line.
It's a long key and will wrap but it must be one line.

insert_nick 2006-09-21 17:51

Quote:

Originally Posted by BanditRider
Check your public key in your authorized_keys file and make sure the key is one line.
It's a long key and will wrap but it must be one line.

It's splitted on several lines. Because of the fact btw the connection freezed sometime, I've decided to uninstall dropbear (unistalling from the Application manager and manually removing /etc/rc2/@S20dropbear and /etc/init.d/*dropbear) and give OpenSSH a try. It works even if it seems somehow slower (but maybe it's a matter of the moment), WinSCP works good too, by the way I'd like to know: where do I have to put the public key of the pair now, in order to let OpenSSH find it? Is the file name still "authorized_keys"? Can it be splitted on several lines as PuttyGen saves it? Where in the net these infos can be found in order to avoid bothering you gentle and busy people there?

fanoush 2006-09-21 18:52

Quote:

Originally Posted by insert_nick

...and this is the authorized_keys file in the n770:

Code:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20060915"
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of 64 scrambled chars...)
(line of some others scrambled chars...)
---- END SSH2 PUBLIC KEY ----

:(

This really does not look like key dropbear or openssh can accept. authorized keys format is - each key on one line in format like

Code:

ssh-rsa ......reallylots(372?)ofrandomletters........ user@machine

insert_nick 2006-09-26 22:51

Thanks, that was the problem! I was using the key which Puttygen saves by chosing to save into a file, rather than the one it displayed in the textarea field.


All times are GMT. The time now is 16:08.

vBulletin® Version 3.8.8