Prosíme přihlašte se nebo zaregistrujte.

Přihlašte se svým uživatelským jménem a heslem.
Vaše pomoc je stále potřeba!

Autor Téma: OpenSSH + Ubuntu 10.04 (vyřešeno)  (Přečteno 1083 krát)

freax

  • Návštěvník
  • Příspěvků: 4
OpenSSH + Ubuntu 10.04 (vyřešeno)
« kdy: 13 Července 2011, 09:38:52 »
Zdravím.
Prosim Vás jak správně nastavit OpenSSH, zvláště pak sshd_config aby vyžadoval autentizaci pomocí privátního a veřejného klíče a vyžadoval také heslo na cílovém počítači? Chtěl bych využívat algoritmus DSA a nechci ukládat passphrase. Jednou už jsem toto nastavoval, ale nějak mi to přestalo fungovat, tak jsem se to rozhodl kompletně přeinstalovat a vygenerovat si nové klíče, což byla zřejmě chyba. Trápím se s tím už několik hodin a když už si myslím, že to mám nakonfigurované správně, nechce mi to spolknout mojí passphrase.. :-/ Poradíte prosím?

Předem díky moc...

tady je debugg:
Kód: [Vybrat]
OpenSSH_5.3p1 Debian-3ubuntu6, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Applying options for *

debug2: ssh_connect: needpriv 0

debug1: Connecting to 192.168.0.1 [192.168.0.1] port 22.

debug1: Connection established.

debug3: Not a RSA1 key file /home/freax/.ssh/id_dsa.

debug2: key_type_from_name: unknown key type '-----BEGIN'

debug3: key_read: missing keytype

debug2: key_type_from_name: unknown key type 'Proc-Type:'

debug3: key_read: missing keytype

debug2: key_type_from_name: unknown key type 'DEK-Info:'

debug3: key_read: missing keytype

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug3: key_read: missing whitespace

debug2: key_type_from_name: unknown key type '-----END'

debug3: key_read: missing keytype

debug1: identity file /home/freax/.ssh/id_dsa type 2

debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024

debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debian-3ubuntu6

debug1: match: OpenSSH_5.3p1 Debian-3ubuntu6 pat OpenSSH*

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu6

debug2: fd 3 setting O_NONBLOCK

debug1: SSH2_MSG_KEXINIT sent

debug3: Wrote 792 bytes for a total of 831

debug1: SSH2_MSG_KEXINIT received

debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

debug2: kex_parse_kexinit: ssh-rsa,ssh-dss

debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib

debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib

debug2: kex_parse_kexinit:

debug2: kex_parse_kexinit:

debug2: kex_parse_kexinit: first_kex_follows 0

debug2: kex_parse_kexinit: reserved 0

debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

debug2: kex_parse_kexinit: ssh-rsa,ssh-dss

debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kex_parse_kexinit: none,zlib@openssh.com

debug2: kex_parse_kexinit: none,zlib@openssh.com

debug2: kex_parse_kexinit:

debug2: kex_parse_kexinit:

debug2: kex_parse_kexinit: first_kex_follows 0

debug2: kex_parse_kexinit: reserved 0

debug2: mac_setup: found hmac-md5

debug1: kex: server->client aes128-ctr hmac-md5 none

debug2: mac_setup: found hmac-md5

debug1: kex: client->server aes128-ctr hmac-md5 none

debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent

debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP

debug3: Wrote 24 bytes for a total of 855

debug2: dh_gen_key: priv key bits set: 137/256

debug2: bits set: 534/1024

debug1: SSH2_MSG_KEX_DH_GEX_INIT sent

debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY

debug3: Wrote 144 bytes for a total of 999

debug3: check_host_in_hostfile: filename /home/freax/.ssh/known_hosts

debug3: check_host_in_hostfile: match line 1

debug1: Host '192.168.0.1' is known and matches the RSA host key.

debug1: Found key in /home/freax/.ssh/known_hosts:1

debug2: bits set: 521/1024

debug1: ssh_rsa_verify: signature correct

debug2: kex_derive_keys

debug2: set_newkeys: mode 1

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug3: Wrote 16 bytes for a total of 1015

debug2: set_newkeys: mode 0

debug1: SSH2_MSG_NEWKEYS received

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug3: Wrote 48 bytes for a total of 1063

debug2: service_accept: ssh-userauth

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug2: key: /home/freax/.ssh/id_dsa (0x7f671cc2d5b0)

debug2: key: /home/freax/.ssh/id_dsa (0x7f671cc28bd0)

debug3: Wrote 64 bytes for a total of 1127

debug1: Authentications that can continue: publickey,password

debug3: start over, passed a different list publickey,password

debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password

debug3: authmethod_lookup publickey

debug3: remaining preferred: keyboard-interactive,password

debug3: authmethod_is_enabled publickey

debug1: Next authentication method: publickey

debug1: Offering public key: /home/freax/.ssh/id_dsa

debug3: send_pubkey_test

debug2: we sent a publickey packet, wait for reply

debug3: Wrote 528 bytes for a total of 1655

debug1: Authentications that can continue: publickey,password

debug1: Offering public key: /home/freax/.ssh/id_dsa

debug3: send_pubkey_test

debug2: we sent a publickey packet, wait for reply

debug3: Wrote 528 bytes for a total of 2183

debug1: Authentications that can continue: publickey,password

debug2: we did not send a packet, disable method

debug3: authmethod_lookup password

debug3: remaining preferred: ,password

debug3: authmethod_is_enabled password

debug1: Next authentication method: password

debug3: packet_send2: adding 64 (len 56 padlen 8 extra_pad 64)

debug2: we sent a password packet, wait for reply

debug3: Wrote 144 bytes for a total of 2327

debug1: Authentication succeeded (password).
« Poslední změna: 13 Července 2011, 16:54:04 od freax »

On

  • Stálý člen
  • **
  • Příspěvků: 1136
    • Operační systémy
Re: OpenSSH + Ubuntu 10.04
« Odpověď #1 kdy: 13 Července 2011, 14:14:53 »
Nepoužívám sice DSA, ale rozdíl v konfiguraci by být neměl...kdyžtak ještě pošli sshd_config ...

A chceš, aby povolil uživatele buď za pomocí hesla nebo ssh klíče, je tak?  Čili default nastavení? V default jde využívat obojího... V tomto případě snad není potřeba nic jiného, než nainstalovat openssh a hotovo..pokud chceš jít přes klíče, vygenerují se klíče na klientských stanicích a hodí se na server do ~/.ssh/authorized_keys, toť vše..
« Poslední změna: 13 Července 2011, 14:16:59 od On »
Asus M2A-VM HDMI, Athlon 64 X2 4800+, 4GB DDR2/800Mhz,Powercolor HD 2600 XT, Ubuntu 10.10
Být posledním nevadí, ale nikdy nesmíte být poslední dvakrát po sobě - Iacocca

freax

  • Návštěvník
  • Příspěvků: 4
Re: OpenSSH + Ubuntu 10.04
« Odpověď #2 kdy: 13 Července 2011, 14:33:28 »
tady je ten sshd_config:
Kód: [Vybrat]
# Package generated configuration file
# See the sshd_config(5) manpage for details

# 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

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication no
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# 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

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

tady je na pastebin: http://pastebin.com/mjN7P37x

Jinak se chci přihlašovat výhradně přes klíče. Nechci jen heslo. Nejlepší by bylo, kdybych vkládal passphrase a ještě k tomu heslo. Pouze přes heslo se přihlásím. Problém je s klíčema :-/ Po vygenerování klíčů sem proved
Kód: [Vybrat]
cat id_dsa.pub >> authorized_keys . Všechno ve složce .ssh má práva 600 a samotná složka 700...

EDIT: ještě koukám, že tam mám zakomentováno "AuthorizedKeysFile    %h/.ssh/authorized_keys", ale i po odkomentování to nefunguje :-/
« Poslední změna: 13 Července 2011, 14:54:46 od freax »

freax

  • Návštěvník
  • Příspěvků: 4
Re: OpenSSH + Ubuntu 10.04
« Odpověď #3 kdy: 13 Července 2011, 16:53:13 »
Tak už jsem na to přišel. Ale že to trvalo :-) Bylo to tím, že skupina nesmí mít právo zapisovat do adresáře /home/user. Pokud tomu tak je, soubor authorized_keys je odmítnut.. Tak kdyby někdo řešil stejnej problém :-)

 

Provoz zaštiťuje spolek OpenAlt.