Start sshd with ZNC (and FTP) in less than 5 steps|sshd über ZNC (und FTP) starten in weniger als 5 Schritten

Heute ist mein sshd auf meinem vServer abgeschmiert und ich wollte den Server nicht neustarten.
Es musste also eine Möglichkeit her, den sshd wieder zu starten.

Today my sshd crashed and I didn’t want to restart my vServer.
So I searched for something to start sshd without restarting the system again and I found something.
To read on hit „Weiterlesen“.

For the English version scroll a little bit down.

German/Deutsch

Benötigt wird:
-ZNC (installiert und gestartet, Modul „webinterface“ oder Nutzermodul „shell“ aktiviert)
-FTP (installiert und gestartet) – es gibt auch eine Möglichkeit, Dateien direkt an das shell Modul zu übertragen – dazu bitte selbst schlau machen. Wenn die Nachfrage groß genug ist, mach ich dafür auche eine Anleitung.
-System mit „expect“ installiert („which expect“ hilft weiter ;))

Bei mir trifft das ganze auf Debian zu, also werde ich auch debianspezifische Pfade verwenden. Diese sind eventuell anzupassen.

Schritt 1:

Via FTP zum Server verbinden.

Schritt 2:

Die folgende Datei nach /home/DU/expect.sh speichern:

#!/usr/bin/expect
set password PASSWORT
spawn /bin/su -c "/etc/init.d/ssh start"
expect "Passwort:"
send "$password\r"
expect eof

(Credits: http://www.bitbull.ch/wiki/index.php/Passwörter_mit_expect_einfüttern)

Anzupassen sind hier die Zeile „set password PASSWORT“ und eventuell die Zeilen „spawn /bin/su -c „/etc/init.d/ssh start““ und „#!/usr/bin/expect“. Und eventuell noch „expect „Passwort:““ bei einem engl. Debian zu „expect „Password:““ ändern.
Das dann speichern und die Rechte auf 777 setzen.

Schritt 3:

In das ZNC Webinterface gehen und prüfen, dass das Nutzermodul „shell“ aktiviert ist.
Danach zum ZNC verbinden.

Schritt 4:

Folgendes eingeben:
/msg *shell cd ~
/msg *shell ./expect.sh

Danach mal in das Fenster „shell“ wechseln und prüfen, ob der sshd erfolgreich gestartet wurde.

Das war’s.
Ich hoffe, es half und ich bin mir sicher, dass das das einzige Tutorial ist, das die Thematik SO aufgreift. 😀

English/Englisch

Needed stuff:
-ZNC (installed and started, module „webinterface“ or user module „shell“ activated)
-FTP (installed and started) – there’s also an option to send files directly to the shell module of ZNC but I don’t know how to do. Please search for yourself. Will add a guide for this if you want to.
-System with installed „expect“ („which expect“ should help ;))

I’ve done this on Debian so you maybe need to edit some lines. If so, I will tell you that you need to edit it.

Step 1:

Connect to your server with FTP.

Step 2:

Save the following as /home/YOU/expect.sh:

#!/usr/bin/expect
set password PASSWORD
spawn /bin/su -c "/etc/init.d/ssh start"
expect "Password:"
send "$password\r"
expect eof

(Credits: http://www.bitbull.ch/wiki/index.php/Passwörter_mit_expect_einfüttern)

Here you need to edit „set password PASSWORD“ and maybe the lines „spawn /bin/su -c „/etc/init.d/ssh start““ and „#!/usr/bin/expect“.
Then save the file and set the permissions to 777.

Step 3:

Login into the ZNC webinterface and check that the user module „shell“ is activated. Then connect to your ZNC server.

Step 4:

Enter the following into your IRC client
/msg *shell cd ~
/msg *shell ./expect.sh

Then switch to the „shell“ window and check that sshd was started succesfully.

That’s it.
I hope that this helped you and I’m sure I’m the only person who solves the problem this way. 😀

5 Gedanken zu „Start sshd with ZNC (and FTP) in less than 5 steps|sshd über ZNC (und FTP) starten in weniger als 5 Schritten

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.