Putty, Debian verbinding dmv DSA keys

Pagina: 1
Acties:

  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
Het zoveelste topic met SSH en het gebruik van keys. Alleen kwam ik er niet uit aan de hand van andere topics of informatie op google. Heb tig manuals doorgelezen, maar ik zie nu door de bomen het bos niet meer. Wie helpt mij even op weg aub, desnoods een link die beschrijft hoe ik het voor elkaar krijg. (openSSH, putty, dsa, protocol 2 )


Ik wil met putty connecten met de user music naar mijn SSH server (debian,openSSH) dmv een private en public key protocol 2 en dmv een gewoon password. Maar zegt de hele tijd Server refused key

Mijn vraag aan jullie, als iemand deze combinatie heeft, putty , openSSH , DSA sleutels + password authorisatie kan iemand dan zijn sshd_config posten. En tevens even vermelden met welke user hij inlogt. Dan kom ik er wel uit hopelijk.

thanks

PS
Nog even een vraagje ik heb ook lopen rommelen (lees remove)met ssh_host_dsa_key en ssh_host_dsa_key.pub in de directory /etc/ssh in deze directory is toch alleen sshd_config van belang?


code:
1
2
3
4
5
Wat verdere informatie:
ssh -v
OpenSSH_3.8.1p1 Debian-8.sarge.4, OpenSSL 0.9.7e 25 Oct 2004

Putty release 0.56

  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
Hieronder dan toch maar even alle stappen die ik doorlopen heb.

Ingelogd met putty met user music met alleen passw authorisatie

Protocol version 2 key generation

Ingelogd als User: music
directory /home/music/.ssh

Bijzonderheden: password ingevoerd bij passphrase
code:
1
2
3
4
5
6
7
8
9
10
music@Debian:~/.ssh$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/music/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/music/.ssh/id_dsa.
Your public key has been saved in /home/music/.ssh/id_dsa.pub.
The key fingerprint is:
58:8d:1b:84:d2:bla bla::7b:ae:51:24 music@Debian
music@Debian:~/.ssh$


Keys in /home/music/.ssh

code:
1
2
-rw-------  1 music music 736 Feb 19 21:49 id_dsa
-rw-r--r--  1 music music 602 Feb 19 21:49 id_dsa.pub


Het bestand id_dsa bevat mijn versie 2 private key
Het bestand id_dsa.pub bevat mijn versie 2 public key


Authorized_keys2, /home/music/.ssh

code:
1
2
3
4
5
6
7
8
music@Debian:~/.ssh$ touch authorized_keys2
music@Debian:~/.ssh$ chmod 600 authorized_keys2
music@Debian:~/.ssh$ cat id_dsa.pub >> authorized_keys2
music@Debian:~/.ssh$ ls
total 12K
-rw-------  1 music music 602 Feb 19 22:01 authorized_keys2
-rw-------  1 music music 736 Feb 19 21:49 id_dsa
-rw-r--r--  1 music music 602 Feb 19 21:49 id_dsa.pub



Ik haal nu met Winscp mijn id_dsa op zodat ik op mijn windows bak met putty kan connecten naar de ssh server. Vervolgens open ik puttygen, ik druk op conversions en import key (id_dsa). Nu druk ik op save private key

Putty opstarten, key selecteren en user music
code:
1
2
3
Using username "music".
Server refused our key
Password:



Hieronder mijn sshd_config
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Debian:/etc/ssh# cat sshd_config
# Package generated configuration file
# See the sshd(8) manpage for defails

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

AllowGroups music
AllowUsers music
DenyGroups root
DenyUsers root


# ...but breaks Pam auth via kbdint, so we have to turn it off
# Use PAM authentication via keyboard-interactive so PAM modules can
# properly interface with the user (off due to PrivSep)
#PAMAuthenticationViaKbdInt no
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 60
PermitRootLogin no
StrictModes yes

DSAAuthentication yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys
AuthorizedKeysFile     /home/music/.ssh/authorized__keys2
# rhosts authentication should not be used
#RhostsAuthentication no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Uncomment to disable s/key passwords
#ChallengeResponseAuthentication no

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes


# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
#PrintLastLog no
KeepAlive no
#UseLogin no

MaxStartups 2:50:10
#Banner /etc/issue.net
#ReverseMappingCheck yes

Subsystem       sftp    /usr/lib/sftp-server


UsePAM yes


En de directory rechten van de bestanden in /etc/ssh
code:
1
2
3
4
5
6
7
8
9
10
Debian:/etc/ssh# ls -al
total 144
drwxr-xr-x   2 root root   4096 Feb 19 22:12 .
drwxr-x--x  78 root root   4096 Feb 19 13:11 ..
-rw-r--r--   1 root root 111892 Nov 28 16:33 moduli
-rw-r--r--   1 root root   1185 Nov 28 16:33 ssh_config
-rw-------   1 root root    668 Feb  2 16:02 ssh_host_dsa_key
-rw-r--r--   1 root root    601 Feb  2 16:02 ssh_host_dsa_key.pub
-rw-r--r--   1 root root   2205 Feb 19 22:08 sshd_config
-rw-r--r--   1 root root   2045 Feb  2 16:02 sshd_config.dpkg-old


Ik hoop dat iemand mij effe kan helpen, thankss

  • frim
  • Registratie: Augustus 2001
  • Niet online
Probeer anders eerst even als user music naar localhost te ssh'en en te kijken of de key dan wel wordt geaccepteerd; dan weet je of het aan putty ligt of aan je server.

  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
frim schreef op zaterdag 19 februari 2005 @ 21:28:
Probeer anders eerst even als user music naar localhost te ssh'en en te kijken of de key dan wel wordt geaccepteerd; dan weet je of het aan putty ligt of aan je server.
Ik zit hier nu thuis op een Win2k bak met putty, en mijn debian bak staat op mijn studentenkamer.
Ik kan wel al gewoon inloggen met putty met passw maar dus nog niet met keys.

Ik heb het volgende gedaan, maar weer niet of dat aansluit bij jou vraag.

ssh -2 -v music@localhost
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
music@Debian:~$ ssh -2 -v music@localhost
OpenSSH_3.8.1p1 Debian-8.sarge.4, OpenSSL 0.9.7e 25 Oct 2004
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/music/.ssh/id_rsa type -1
debug1: identity file /home/music/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1 Deb
ian-8.sarge.4
debug1: match: OpenSSH_3.8.1p1 Debian-8.sarge.4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1 Debian-8.sarge.4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
The authenticity of host 'localhost (127.0.0.1)' can't be established.
DSA key fingerprint is 04:49:ca:3b:5e:bc:06:b7:ba:43:e6:60:9e:18:98:57.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (DSA) to the list of known hosts.
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interacti
ve
debug1: Next authentication method: publickey
debug1: Trying private key: /home/music/.ssh/id_rsa
debug1: Offering public key: /home/music/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interacti
ve
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentication succeeded (keyboard-interactive).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: channel 0: free: client-session, nchannels 1
Read from remote host localhost: Connection reset by peer
Connection to localhost closed.
debug1: Transferred: stdin 0, stdout 0, stderr 92 bytes in 2.0 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 46.0
debug1: Exit status -1
music@Debian:~$


Wat kan ik hier uit afleiden? Sorry voor de stomme vraag :)

  • Gondor
  • Registratie: September 2003
  • Laatst online: 01:33
In je config file staat: authorized__keys2 (met 2 lage strepen)
code:
1
AuthorizedKeysFile     /home/music/.ssh/authorized__keys2


Maar je zet je publickey in "authorized_keys2", niet met 2 lage strepen maar met 1.

"Peace cannot be kept by force. It can only be achieved by understanding"-Albert Einstein-


  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
Gondor schreef op zondag 20 februari 2005 @ 00:03:
In je config file staat: authorized__keys2 (met 2 lage strepen)
code:
1
AuthorizedKeysFile     /home/music/.ssh/authorized__keys2


Maar je zet je publickey in "authorized_keys2", niet met 2 lage strepen maar met 1.
Bedankt voor je tip, ik heb het verandert en opnieuw opgestart maar het werkt nog steeds niet. Hij zegt nog steeds "server refused key"

Iemand nog een idee??

  • igmar
  • Registratie: April 2000
  • Laatst online: 31-01 23:50

igmar

ISO20022

Bram schreef op zondag 20 februari 2005 @ 19:10:

Bedankt voor je tip, ik heb het verandert en opnieuw opgestart maar het werkt nog steeds niet. Hij zegt nog steeds "server refused key"
sshd in debug mode starten, dan krijg je debug uitvoer naar de console, en ook de reden waarom een pubkey wordt geweigerd. Vaak een permissieprobleem is mijn ervaring.

  • BoAC
  • Registratie: Februari 2003
  • Laatst online: 13-02 16:47

BoAC

Memento mori

code:
1
AuthorizedKeysFile     /home/music/.ssh/authorized__keys2

is bij mij:
code:
1
#AuthorizedKeysFile     .ssh/authorized_keys

Het lijkt er dus op dat je geen 'home-dir' moet meegeven ;)

[ Voor 173% gewijzigd door BoAC op 21-02-2005 10:51 ]


  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
Goed mensen ik heb het voor elkaar, bedankt voor alle tips en suggesties!!! Voor de volledigheid ga ik hier toch even mijn configuratie files en permissies neerzetten, mochten mensen dan ook een probleem zoals dit hebben dan kunnen ze naar dit topic kijken. Het luistert allemaal heel nauw met permissies heb ik al wel gemerkt.


Hoe ik sleutels aangemaakt heb en de rest zie je allemaal bovenin in topic.

Hier nog even mijn sshd_config en daaronder de diverse dirs en files met hun permissies. Mocht het nog beter kunnen dan hoor ik dat graag!! Ik ben ook maar een leek op dit gebied.

Permissies ( zie ook je /var/log/auth.log voor permissie problemen)

mijn .ssh dir in mijn home directory (chmod 700 .ssh )
code:
1
2
music@Debian:~/.ssh$ ls -ld
drwx------  2 music music 4.0K Feb 19 22:34 .


Files in mijn .ssh dir.
code:
1
2
3
4
5
6
7
music@Debian:~/.ssh$ ls -al
total 20K
drwxr-xr-x  18 music music 4.0K Feb 21 00:34 ..
drwx------   2 music music 4.0K Feb 19 22:34 .
-rw-------   1 music music  599 Feb 19 22:34 known_hosts
-rw-------   1 music music  602 Feb 19 22:01 authorized_keys2
-rw-------   1 music music  602 Feb 19 21:49 id_dsa.pub

chmod 600 authorized_keys2
chmod 600 knows_hosts id_dsa.pub


sshd_config

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

AllowGroups music
AllowUsers music
DenyGroups root
DenyUsers root



# ...but breaks Pam auth via kbdint, so we have to turn it off
# Use PAM authentication via keyboard-interactive so PAM modules can
# properly interface with the user (off due to PrivSep)
#PAMAuthenticationViaKbdInt no
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
#ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 60
PermitRootLogin no
StrictModes yes

DSAAuthentication yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys
AuthorizedKeysFile     .ssh/authorized_keys2
# rhosts authentication should not be used
#RhostsAuthentication no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Uncomment to disable s/key passwords
#ChallengeResponseAuthentication no

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no


# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
#PrintLastLog no
KeepAlive no
#UseLogin no

MaxStartups 2:50:10
#Banner /etc/issue.net
#ReverseMappingCheck yes

Subsystem       sftp    /usr/lib/sftp-server


UsePAM yes

  • pierre-oord
  • Registratie: April 2002
  • Laatst online: 15-01 10:55
Als je debian draait, kun je dan niet even iets met dpkg-reconfigure ofzo doen? Standaard werkt SSH bij debian gewoon out-of-the-box :)

Ondernemer in tech (oud LOQED.com, nu UpToMore.com)


  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
pierre-oord schreef op maandag 21 februari 2005 @ 15:33:
Als je debian draait, kun je dan niet even iets met dpkg-reconfigure ofzo doen? Standaard werkt SSH bij debian gewoon out-of-the-box :)
Ik moest ssh handmatig met apt-get installeren, stond er dus nog niet standaard op. Kan je volgens mij aangeven bij de installatie.

Ik heb toch nog even jullie raad nodig, voor het laatste kleine probleempje, dan werkt het helemaal.

Ik kan nu dus met mijn private DSA key inloggen, maar het kan ook nog steeds met het passw van de user zonder de key.

Nu heb ik uitgezocht dat je dan de regel:

PasswordAuthentication no op NO moest zetten in je sshd_config. Dit heb ik dus even gedaan maar het kan nu dus nog steeds op beide manieren. Iemand een suggestie? Thanks

  • BoAC
  • Registratie: Februari 2003
  • Laatst online: 13-02 16:47

BoAC

Memento mori

Kijk ff bij man sshd_conf en dan UsePam ;)

Wat was nu de eigenlijke reden dat het niet werkte?

  • Bram
  • Registratie: Oktober 1999
  • Niet online

Bram

..........

Topicstarter
BoAC schreef op maandag 21 februari 2005 @ 16:33:
Kijk ff bij man sshd_conf en dan UsePam ;)
Wat was nu de eigenlijke reden dat het niet werkte?
Bedankt voor de tip Aalderd, het werkt nu helemaal!! Dingen die ik heb verandert:

UsePAM no
PasswordAuthentication no


De reden dat het niet werkte was uiteindelijk toch de permissies, ik heb wel jou suggestie opgevolgd door AuthorizedKeysFile /home/music/.ssh/authorized__keys2 te veranderen in .ssh/authorized_keys2 zoals je zei. Dat maakte voor mij niets uit, heb ik het idee omdat het toen nog niet werkte.

Uit log bestand:
code:
1
Feb 21 13:46:57 debian sshd[407]: Authentication refused: bad ownership or modes for directory /home/music/.ssh


Thanks!!
Pagina: 1