Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Simple-SSH Script lässt Javascript Adapter abstürzen

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Simple-SSH Script lässt Javascript Adapter abstürzen

    This topic has been deleted. Only users with topic management privileges can see it.
    • TeNNo2k5
      TeNNo2k5 last edited by

      Vielleicht als Alternative einfach normales SSH mit Public-Key-Authentifizierung verwenden, das entspricht dem normalen Linux Sicherheitskonzept da Passwörter nicht in Skripten hinterlegt sind und bringt den Javascript Adapter nicht durcheinander.

      Anleitung zum Einrichten:

      https://www.thomas-krenn.com/de/wiki/OpenSSH_Public_Key_Authentifizierung_unter_Ubuntu

      Wenn die Verbindung eingerichtet ist einfach die Keys zum iobroker User übertragen:

      cp -rT /home/pi/.ssh/ /home/iobroker/.ssh 
      chown iobroker /home/iobroker/.ssh/authorized_keys 
      chown iobroker /home/iobroker/.ssh/id_rsa 
      chown iobroker /home/iobroker/.ssh/known_hosts
      
      joergeli 1 Reply Last reply Reply Quote 0
      • joergeli
        joergeli @TeNNo2k5 last edited by

        @TeNNo2k5
        ... viele Wege führen nach Rom
        Allerdings scheint mir diese Variante für "Nicht-Linux-Spezies" doch recht kompliziert.

        Ich hatte anfangs auch nicht mit solchen Problemen bei einem Shutdown via SSH gerechnet.
        Habe aber - Dank Eurer Hilfe - eine Lösung gefunden und vor allem einiges dazugelernt.

        Danke nochmals
        Jörg

        1 Reply Last reply Reply Quote 0
        • K
          KHK @joergeli last edited by

          @joergeli said in Simple-SSH Script lässt Javascript Adapter abstürzen:

          Also nicht simple-ssh verwenden, sondern node-ssh.

          Dieses node-ssh muss das irgendwie neu installiert werden oder was muss gemacht werden?

          Ich habe das mal probiert, aber es kommt die Meldung "TypeError: node_ssh is not a constructor"

          Karl

          joergeli E 2 Replies Last reply Reply Quote 0
          • joergeli
            joergeli @KHK last edited by

            @khk
            Es sollte reichen, node-ssh als zusätzliches Modul in der Konfiguration des JS-Adapters mit einzutragen.
            IMHO wird es dann automatisch installiert.
            js-adapter-konfiguration.jpg
            Gruß
            Jörg

            1 Reply Last reply Reply Quote 0
            • E
              el_malto @KHK last edited by el_malto

              @khk du kannst das Skript von oben nicht mehr verwenden. Es haben sich die Aufrufe geändert. Musst dir mal das Example angucken -> https://www.npmjs.com/package/node-ssh
              Ich hab meine Skripte so angepasst:

              const {NodeSSH} = require('node-ssh')
              const ssh = new NodeSSH()
              
              ssh.connect({
                host: '192.168.xxx.xxx',
                username: '<user>',
                password: '<pass>'
              }).then(() => {
                ssh.execCommand("<command>");
              })
              
              joergeli 1 Reply Last reply Reply Quote 0
              • joergeli
                joergeli @el_malto last edited by

                @el_malto
                Was ist da jetzt anders als im obigen Script?
                (Außer daß Du NodeSSH in geschweiften Klammern? als Konstante deklariert hast)

                Oder übergibst Du das password nicht nochmals im ssh.execCommand?

                Gruß
                Jörg

                E 1 Reply Last reply Reply Quote 0
                • E
                  el_malto @joergeli last edited by el_malto

                  @joergeli es ist jetzt nicht mehr node_ssh sondern NodeSSH. Deswegen auch der Fehler.

                  "TypeError: node_ssh is not a constructor"
                  

                  Ist im Changelog auch drin:
                  https://github.com/steelbrain/node-ssh/blob/master/CHANGELOG.md#1100

                  joergeli 1 Reply Last reply Reply Quote 0
                  • joergeli
                    joergeli @el_malto last edited by

                    @el_malto
                    ahhh, OK.
                    Ich habe es bei mir jetzt auch wie bei Dir angepasst.

                    const {NodeSSH} = require('node-ssh')
                    const ssh = new NodeSSH()
                    

                    Nebenbei:
                    Bei mir kam keine Fehlermeldung wie bei @KHK, weil ich irgendwann schon mal folgende Anpassung vorgenommen hatte:

                    var node_ssh = require('node-ssh').NodeSSH;
                    var ssh = new node_ssh();
                    

                    (Hatte ich wohl irgendwo im Forum gefunden)

                    Gruß und Danke
                    Jörg

                    1 Reply Last reply Reply Quote 1
                    • H
                      Hansi1234 last edited by

                      Hat jemand aktuell noch ein ssh script am laufen? Ich bekomme das Modul nicht installiert:

                      javascript.0	2021-04-26 07:54:48.372	error	(22266) Cannot install nodessh: 1
                      javascript.0	2021-04-26 07:54:48.358	error	(22266) npm ERR! A complete log of this run can be found in: npm ERR! /home/iobroker/.npm/_logs/2021-04-26T05_54_48_349Z-debug.log
                      javascript.0	2021-04-26 07:54:48.357	error	(22266)
                      javascript.0	2021-04-26 07:54:48.348	error	(22266) ERR! 404 Not Found - GET https://registry.npmjs.org/nodessh - Not found npm ERR! 404 npm ERR! 404 'nodessh@latest' is not in the npm registry. npm ERR! 404 You should bug the author to publi
                      javascript.0	2021-04-26 07:54:48.346	error	(22266) npm
                      javascript.0	2021-04-26 07:54:48.338	error	(22266) ERR! code E404
                      javascript.0	2021-04-26 07:54:48.336	error	(22266) npm
                      javascript.0	2021-04-26 07:54:46.257	info	(22266) npm install nodessh --production (System call)
                      
                      Asgothian 1 Reply Last reply Reply Quote 0
                      • Asgothian
                        Asgothian Developer @Hansi1234 last edited by

                        @hansi1234 Das könnte daran liegen das das Module node-ssh heisst, nicht nodessh

                        A.

                        1 Reply Last reply Reply Quote 0
                        • D
                          Dragon last edited by

                          Ich bekomme folgende Fehlermeldung, wenn ich das Skript starte. Hat jemand eine Idee?

                          
                          javascript.0	2021-09-28 16:22:28.756	error	(2289) at Script.runInContext (vm.js:130:18)
                          javascript.0	2021-09-28 16:22:28.755	error	(2289) at script.js.common.Automatisierung.Geräte.3D_Drucker.Shutdown_OctPi:19:3
                          javascript.0	2021-09-28 16:22:28.755	error	(2289) at script.js.common.Automatisierung.Geräte.3D_Drucker.Shutdown_OctPi:2:11
                          javascript.0	2021-09-28 16:22:28.754	error	(2289) script.js.common.Automatisierung.Geräte.3D_Drucker.Shutdown_OctPi: TypeError: node_ssh is not a constructor
                          
                          Glasfaser 1 Reply Last reply Reply Quote 0
                          • Glasfaser
                            Glasfaser @Dragon last edited by

                            @dragon sagte in Simple-SSH Script lässt Javascript Adapter abstürzen:

                            Automatisierung.Geräte.3D_Drucker.Shutdown_OctPi

                            Zeige mal dein Script

                            D 1 Reply Last reply Reply Quote 0
                            • D
                              Dragon @Glasfaser last edited by

                              @glasfaser
                              Vielen Dank für das Hilfsangebot, aber ich habe den Fehler gefunden. Er saß teilweise vor der Tastatur

                              var node_ssh = require('node-ssh').NodeSSH;
                              var ssh = new node_ssh();
                              

                              erstens das hier.
                              Zweitens: das Passwort war falsch und die IP Adresse stimmte nicht.... Vll ist es an der Zeit für heute Feierabend zu machen.... 😁

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post

                              Support us

                              ioBroker
                              Community Adapters
                              Donate

                              827
                              Online

                              31.7k
                              Users

                              79.6k
                              Topics

                              1.3m
                              Posts

                              11
                              23
                              2962
                              Loading More Posts
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes
                              Reply
                              • Reply as topic
                              Log in to reply
                              Community
                              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                              The ioBroker Community 2014-2023
                              logo