![Bei der Automatisierung der SSH-Anmeldung reagiert die Remote-Shell nicht mehr und es kommt zu einem Rückfall auf das Client-Terminal (ohne Fehler).](https://rvso.com/image/1087138/Bei%20der%20Automatisierung%20der%20SSH-Anmeldung%20reagiert%20die%20Remote-Shell%20nicht%20mehr%20und%20es%20kommt%20zu%20einem%20R%C3%BCckfall%20auf%20das%20Client-Terminal%20(ohne%20Fehler)..png)
Ich habe ein Problem mit dem Tool, außer unter Ubuntu 14.04 LTS. Ich möchte SSH-Anmeldungen bei einigen Sophos UTM-Firewalls automatisieren und meine Rechte direkt danach mit „sudo su -“ und dem richtigen Passwort erweitern. Ich muss mir keine Gedanken über Passwörter im Klartext machen, da mein Skript direkt aus dem KeePass-URL-Feld ausgeführt wird (Doppelklick führt das Skript aus und füllt es mit den richtigen Passwörtern über agrument/KeePass {Placeholder} hinter dem Skript). Ich habe es geschafft, all dies zu erledigen, außer dass ich eine Remote-Root-Shell habe, die keine Befehle ausführt und die Verbindung zu meinem Ubuntu-System „abbricht“. Der Befehl, den ich remote ausführen möchte, wird also 4-5 Sekunden lang nicht ausgeführt und dann plötzlich auf dem Ubuntu-System ausgeführt, ohne mir mitzuteilen, was passiert ist.
Was muss ich tun, um eine voll funktionsfähige Remote-Shell zu haben? SSH-Keys und direkter Root-Login sind für mich keine Lösung, da wir zu viele Sophos UTMs im Einsatz haben.
Erklärte Dinge, die passieren:
sshtool.sh:
#!/usr/bin/expect -f
spawn sshpass -pPASSWORD ssh -t [email protected] "sudo su -"
expect -- "oot's password:"
send "PASSWORD\r"
expect -- "/root #"
expect eof
What happens in the terminal:
vct@vct-virtual-machine:~$ ./sshtool.sh
spawn sshpass -pPASSWORD ssh -t [email protected] sudo su -
root's password:
utm:/root # whoami
# *enter*
# not reacting for 4-5 seconds
vct@vct-virtual-machine:~$ whoami
vct
vct@vct-virtual-machine:~$
Das Ändern des Skripts auf diese Weise hilft nicht gegen das Problem des Verbindungsabbruchs:
sshtool.sh:
#!/usr/bin/expect -f
spawn ssh [email protected]
expect -- "password:"
send "PASSWORD\r"
expect -- "/home/login > "
send -- "sudo su -\r"
expect -- "oot's password:"
send "PASSWORD\r"
expect -- "/root #"
send -- "whoami\r"
expect eof
vct@vct-virtual-machine:~$ ./sshtool.sh
spawn ssh [email protected]
[email protected]'s password:
Last login: Mon Apr 18 09:14:41 2016 from 192.168.1.44
Sophos UTM
(C) Copyright 2000-2015 Sophos Limited and others. All rights reserved.
Sophos is a registered trademark of Sophos Limited and Sophos Group.
All other product and company names mentioned are trademarks or registered
trademarks of their respective owners.
For more copyright information look at /doc/astaro-license.txt
or http://www.astaro.com/doc/astaro-license.txt
NOTE: If not explicitly approved by Sophos support, any modifications
done by root will void your support.
<M> loginuser@utm:/home/login > sudo su -
root's password:
# Following "whoami" directly executed by the script itself works fine
<M> utm:/root # whoami
root
# After 4-5 seconds, it's dropping the connection again
<M> utm:/root # vct@vct-virtual-machine:~$
Dank im Voraus!
Antwort1
Ich hatte ein ähnliches Problem. Das Problem bestand darin, dass meine Remote-.bashrc-Datei einige Zeilen enthielt, die nichts taten, wenn sie nicht interaktiv ausgeführt wurden.