From: =?iso-8859-2?Q?Radek_Krej=E8a?= on
Hello,

I am trying connect to freebsd. I have php 5.3.2 installed. I have to connect using public keys, but without succes. Function ssh2_connect throws me following error (then I have invalid resource for function ssh2_auth_pubkey_file)...

PHP Warning: ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption keys in /usr/home/radek/pokus.php on line 14

Warning: ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption keys in /usr/home/radek/pokus.php on line 14
PHP Warning: ssh2_connect(): Unable to connect to test.starnet.cz in /usr/home/darius/pokus_nat.php on line 14

Warning: ssh2_connect(): Unable to connect to test.starnet.cz in /usr/home/radek/pokus.php on line 14

Here is code:

<?php
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'hostkey' => 'ssh-dss',
'client_to_server' => array(
'crypt' => '3des-cbc',
'mac' => 'hmac-md5',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => '3des-cbc',
'mac' => 'hmac-md5',
'comp' => 'none'));

$connection = ssh2_connect('test.starnet.cz', 22, array('hostkey'=>'ssh-rsa'), $methods);
?>


I got the same error without using methods variable.

Thank you for advice.

Radek
From: "Daniel P. Brown" on
2010/6/23 Radek Krejča <radek.krejca(a)starnet.cz>:
>
> PHP Warning:  ssh2_connect(): Error starting up SSH connection(-5): Unable to exchange encryption keys in /usr/home/radek/pokus.php on line 14

Make sure that....

.... the key file exists by that name in the location you're
specifying (hint: use a full path).
.... it is the right key for that server.
.... the permissions on the file are very strict (chmod 0400 ssh-rsa).

--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown(a)parasane.net || danbrown(a)php.net
http://www.parasane.net/ || http://www.pilotpig.net/
From: =?iso-8859-2?Q?Radek_Krej=E8a?= on

Make sure that....

.... the key file exists by that name in the location you're
specifying (hint: use a full path).
.... it is the right key for that server.
.... the permissions on the file are very strict (chmod 0400 ssh-rsa).


I got error message immediately after $connection = ssh2_connect('test.starnet.cz', 22, array('hostkey'=>'ssh-rsa'), $methods);, so $connection is invalid resource for other function.

Radek
From: "Daniel P. Brown" on
2010/6/23 Radek Krejča <radek.krejca(a)starnet.cz>:
>
>    Make sure that....
>
>        .... the key file exists by that name in the location you're
> specifying (hint: use a full path).
>        .... it is the right key for that server.
>        .... the permissions on the file are very strict (chmod 0400 ssh-rsa).
>
>
> I got error message immediately after $connection = ssh2_connect('test.starnet.cz', 22, array('hostkey'=>'ssh-rsa'), $methods);, so $connection is invalid resource for other function.

Right.... point being? Your connection instantiation includes the
key file denotation. Did you check the things I mentioned?

--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown(a)parasane.net || danbrown(a)php.net
http://www.parasane.net/ || http://www.pilotpig.net/
From: =?iso-8859-2?Q?Radek_Krej=E8a?= on
>
> Make sure that....
>
> .... the key file exists by that name in the location you're
> specifying (hint: use a full path).
Its in ssh2_auth_public..., yes, I am using full path there.
> .... it is the right key for that server.
Yes, I use it with ssh command from line on the same computer.
> .... the permissions on the file are very strict (chmod 0400 ssh-rsa).
My private key has 0400

>
>
> I got error message immediately after $connection = ssh2_connect('test.starnet.cz', 22, array('hostkey'=>'ssh-rsa'), $methods);, so $connection is invalid resource for other function.

I have rsa keys, but if I use ssh-dss (hostkey), Its without warning - but I cant connect with keys.

Radek