Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

FreeBSD, Gentoo, openSUSE, CentOS, Ubuntu, Debian
rǃppz
Posts: 127
Joined: 2003-04-02 14:14
 

Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by rǃppz »

Hallo,

leider hab ich mich zu später schlafloser Stunde von meinem Rootserver ausgesperrt, habe dummerweise Port 22 anstatt 21 auf eine andere IP weitergeleitet. Nun komm ich nicht natürlich nicht mehr auf den Server um das Rückgänig zu machen.

Also habe ich eine PHP Shell installiert, welche über suphp ausgeführt wird, nur leider kann ich damit die iptables Regeln nicht löschen, da /etc/init.d/iptables clear Root benötigt.

Ein su funktioniert dank nicht vorhandenem Terminal leider auch nicht und von einem sudo bekomme ich keine Antwort. Habe bereits versucht per sudo -u root -p passwort /etc/init.d/iptables clear und rm -Rf /var/lib/iptables/autosave auszuführen, nur leider bekomme ich als Antwort immer nur
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things:

#1) Respect the privacy of others.
#2) Think before you type.

passwort
Damit komme ich also auch nicht unbedingt weiter, leider habe ich keinen kleinen SSH Daemon gefunden, denn ich per wget und gcc compielen kann, die Scriptkiddie Methode eben. OpenSSH bringt beim compielen wohl irgendwo einen Error, den ich leider über die PHP Shell nich zurück bekomme. Leider bietet mein Hoster auch keine RemoteConsole oder ein RescueSystem. Hat noch jemand eine Idee wie ich das Problem am schnellsten lösen könnte? Ich denke per sudo könnte es funktionieren, nur leider bekomme ich da auch keine Antwort, bzw ich weiß nicht ob das Passwort akzeptiert wurde oder einfach danach von sudo unter den Promt angehängt wurde.

Vielen Dank
mattiass
Userprojekt
Userprojekt
Posts: 608
Joined: 2005-12-16 17:57
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by mattiass »

R!ppZ wrote:
Damit komme ich also auch nicht unbedingt weiter, leider habe ich keinen kleinen SSH Daemon gefunden, denn ich per wget und gcc compielen kann, die Scriptkiddie Methode eben.
Nimm dropbear! Bau zuhause ein statisch gelinktes Binary und beame das hoch. Wenn Du hilfe beim Startkommando und der Schlüsselerzeugung brauchst, melde Dich hier nochmal.

BTW: Kannst Du keinen normalen SSH mit einem anderen Port starten? Apache stoppen, mit "sed" den Port in der SSH-Config austauschen und dann SSH auf Port 80 starten?

Und hat Dein Provider keine serielle Konsole? Oder Rettungssystem?
rǃppz
Posts: 127
Joined: 2003-04-02 14:14
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by rǃppz »

Ne Rettungssysteme gibts leider nicht.
Habe jetzt einen neuen Hostkey erzeugt per
ssh-keygen -f hostkey2 -t rsa
und dann per /usr/sbin/sshd -d -h /var/www/web5/html/hostkey2 -p 1337
einen SSH Server geöffnet nur Einloggen kann ich mich leider nicht, aber der Dienst selber lauscht schon :)
Habe es per root und über einen normalen user versucht, es erscheint in der PHP Shell nur
debug1: userauth-request for user web1 service ssh-connection method keyboard-interactive
debug1: attempt 1 failures 1
debug1: keyboard-interactive devs
debug1: auth2_challenge: user=web1 devs=
debug1: kbdint_alloc: devices ''
Failed keyboard-interactive for web1 from 84.154.xxx.xx port 1292 ssh2
debug1: userauth-request for user web1 service ssh-connection method password
debug1: attempt 2 failures 2
mattiass
Userprojekt
Userprojekt
Posts: 608
Joined: 2005-12-16 17:57
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by mattiass »

R!ppZ wrote:
/usr/sbin/sshd -d -h /var/www/web5/html/hostkey2 -p 1337
Warum nen neuen Hostkey???
rǃppz
Posts: 127
Joined: 2003-04-02 14:14
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by rǃppz »

Weil der bisherige in /etc/.. liegt und ich leider keinen Zugriff darauf habe, Permission denied.
$ /usr/sbin/sshd -d
debug1: sshd version OpenSSH_3.4p1 Debian 1:3.4p1-1.woody.3
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.
Wie gehe ich jetzt am besten vor?
mattiass
Userprojekt
Userprojekt
Posts: 608
Joined: 2005-12-16 17:57
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by mattiass »

R!ppZ wrote: Wie gehe ich jetzt am besten vor?
Probier mal nen Dropbear.
rǃppz
Posts: 127
Joined: 2003-04-02 14:14
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by rǃppz »

Warum mit einem anderen SSH Daemon?

OpenSSH läuft ja, mit einem neuen Hostkey nur kann ich mich leider nicht erfolgreich authentifizieren. Mit Dropbear sollte ich ja an dem gleichen Problem stehen.
mattiass
Userprojekt
Userprojekt
Posts: 608
Joined: 2005-12-16 17:57
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by mattiass »

R!ppZ wrote:Warum mit einem anderen SSH Daemon?

OpenSSH läuft ja, mit einem neuen Hostkey nur kann ich mich leider nicht erfolgreich authentifizieren.
Dann editier besser mal die known_hosts...
rǃppz
Posts: 127
Joined: 2003-04-02 14:14
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by rǃppz »

Auf der Clientseite?

Auch wenn ich versuche das Passwort abzuschalten funktioniert es leider nicht. Gegen welche Datenquelle wird denn dabei Authentifiziert gegen /etc/passwd?
/usr/sbin/sshd -d -h /var/www/web5/html/hostkey2 -p 1377 -o 'PermitRootLogin without-password'
debug1: sshd version OpenSSH_3.4p1 Debian 1:3.4p1-1.woody.3
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
debug1: setgroups() failed: Operation not permitted
debug1: Bind to port 1377 on 0.0.0.0.
Server listening on 0.0.0.0 port 1377.
debug1: Server will not fork when running in debugging mode.
Connection from 84.154.2xx.xx port 1955
debug1: Client protocol version 2.0; client software version PuTTY-Release-0.56
debug1: no match: PuTTY-Release-0.56
Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.4p1 Debian 1:3.4p1-1.woody.3
debug1: list_hostkey_types: ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: client->server aes256-cbc hmac-sha1 none
debug1: kex: server->client aes256-cbc hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST_OLD received
debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent
debug1: dh_gen_key: priv key bits set: 248/512
debug1: bits set: 1592/3191
debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT
debug1: bits set: 1590/3191
debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent
debug1: kex_derive_keys
debug1: newkeys: mode 1
debug1: cipher_init: set keylen (16 -> 32)
debug1: SSH2_MSG_NEWKEYS sent
debug1: waiting for SSH2_MSG_NEWKEYS
debug1: newkeys: mode 0
debug1: cipher_init: set keylen (16 -> 32)
debug1: SSH2_MSG_NEWKEYS received
debug1: KEX done
debug1: userauth-request for user root service ssh-connection method none
debug1: attempt 0 failures 0
debug1: Starting up PAM with username "root"
debug1: PAM setting rhost to "pasdfsadf.dip.t-dialin.net"
Failed none for root from 84.154.xxx.xxx port 1955 ssh2
Failed none for root from 84.154.2xxx.xxx port 1955 ssh2
debug1: userauth-request for user root service ssh-connection method keyboard-interactive
debug1: attempt 1 failures 1
debug1: keyboard-interactive devs
debug1: auth2_challenge: user=root devs=
debug1: kbdint_alloc: devices ''
Failed keyboard-interactive for root from 84.154.xxx.xxx port 1955 ssh2
debug1: userauth-request for user root service ssh-connection method password
debug1: attempt 2 failures 2
Failed password for root from 84.154.xxx.xxx port 1955 ssh2
Failed password for root from 84.154.xxx.xxx port 1955 ssh2
debug1: userauth-request for user root service ssh-connection method none
debug1: attempt 3 failures 3
Failed none for root from 84.154.xxx.xxx port 1955 ssh2
debug1: userauth-request for user root service ssh-connection method keyboard-interactive

CUT

debug1: Calling cleanup 0x806be5c(0x0)
debug1: Calling cleanup 0x8052b48(0x0)
debug1: Calling cleanup 0x806be5c(0x0)
Edit:

So jetzt wirds interessanter, der PAM Service kann wohl nicht auf die shadow zugreifen, siehe

debug1: PAM Password authentication accepted for user "web1"
PAM rejected by account configuration[9]: Authentication service cannot retrieve authentication info.

Jetzt bin ich langsam wirklich Ratlos....
User avatar
Joe User
Project Manager
Project Manager
Posts: 11186
Joined: 2003-02-27 01:00
Location: Hamburg
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by Joe User »

Code: Select all

echo "UsePAM no" >> /etc/ssg/sshd_config
/etc/init.d/sshd restart
BTW: dropbear ist für solche frickeleien besser geeignet...
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
rǃppz
Posts: 127
Joined: 2003-04-02 14:14
 

Re: Per IP-Tables ausgesperrt :( SSH Port nicht mehr erreichbar!

Post by rǃppz »

Habe mittlerweile aufgegeben und im RZ angerufen, die haben schnell die iptables Regeln gelöscht und schon funktioniert alles wieder.
Trotzdem vielen Dank für die Hilfe.