Si vos plugins Jeedom (ex. Homeptalk) n’arrivent pas à se connecter en SSH au Mac alors que ssh marche en ligne de commande, voici la solution.
La solution est donc d’assouplir légèrement la configuration SSH côté macOS pour réactiver la compatibilité avec libssh2, uniquement pour l’adresse IP de Jeedom.
N’oubliez pas de compléter avec vos informations :
<IP_MAC>
<IP_JEEDOM>
<UTILISATEUR_MAC>
<MOTDEPASSE_MAC>
1. Sur le Mac en ssh: autoriser Jeedom par mot de passe
Créer un fichier dédié :
sudo tee /etc/ssh/sshd_config.d/jeedom-pass.conf >/dev/null <<'CONF'
Match Address <IP_JEEDOM>
PasswordAuthentication yes
KbdInteractiveAuthentication yes
MaxAuthTries 6
CONF
Toujours sur le Mac ajouter compatibilité crypto pour libssh2
sudo tee /etc/ssh/sshd_config.d/compat-global.conf >/dev/null <<'CONF'
KexAlgorithms +diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
Ciphers +aes128-ctr,aes192-ctr,aes256-ctr
MACs +hmac-sha2-256,hmac-sha1
HostKeyAlgorithms +ecdsa-sha2-nistp256,ssh-ed25519,rsa-sha2-256,ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
CONF
Redémarrer le SSH sur le Mac
sudo /usr/sbin/sshd -t && echo "Syntaxe OK"
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
2. Sur Jeedom en ssh
Créer /tmp/ssh2_pass_test.php :
<?php
$host='<IP_MAC>'; $user='<UTILISATEUR_MAC>'; $pass='<MOTDEPASSE_MAC>';
$c=@ssh2_connect($host,22) or die("KO connect\n");
@ssh2_auth_password($c,$user,$pass) or die("KO auth\n");
$s=ssh2_exec($c,'echo OK-PHP && uname -a'); stream_set_blocking($s,true);
echo stream_get_contents($s),"\n";
Test :
sudo -u www-data php /tmp/ssh2_pass_test.php
Et voilà ![]()