Re: IPTABLES: Per erfolgreichem SSH Login Ports öffnen



Achim Lindt <lindt@xxxxxxxxxxxxxxxxxxxx>:
> Ein Server hat alle Ports nach aussen dicht, bis auf SSH.
> Wenn sich nun ein User von außen per SSH eingeloggt hat, werden mit IPTABLES
> weitere Ports für diese IP geöffnet.
>
> Wie das ganze mit Portknocking funktioniert habe ich in Grundzügen
> verstanden, allerdings möchte ich so den SSH als Schlüssel für weitere Ports
> nutzen. Also sollen weitere Ports z.B. nur mit dem korrekten Keyfile
> geöffnet werden.
>
> Ich könnte ja irgendein Skript deponieren was beim Login ausgeführt wird,
> das Problem wären aber die benötigten root-Rechte.
>
> Für Vorschläge, Links u.ä. Hilfe wäre ich sehr dankbar. Vielleicht habe ich
> ja auch nur ein riesiges Brett vorm Kopf :-)

Entkopple doch den Teil, der iptables aufruft, von dem teil, der
mitbekommt, wenn sich jemand per ssh einloggt.

Einige Beispiele:

1) Cron: installiere einen root-cronjob der jede minute nachschaut,
wer von wo aus per ssh eingeloggt ist, und mit iptables ggf.
aenderungen am aktuellen netfilter regelwerk durchfuehrt. -> keine
Aenderung fuer die Nutzer, alles laeuft "automagisch". Max 59 sek
Verzoegerung allerdings fuers freischalten, wenn sich jemand grade
nach lauf des scripts einlogggt.
Vorteil: Einfach, robust gegen User (keine direkte kommunikation user
<-> root-script, kein bufferoverflowmoeglichkeit hier)
Nachteil: laeuft nur minuetlich (min)

2) daemon unter UID=0 mit lokalem, world-writeable socket, der
auf User-input wartet. Kann auch ein shellscript sein. Der user
schreibt irgendwas oder was spezielles auf den socket, z.B. in
seinem login-script, und der daemon oeffnet die ports.
Vorteil: ports werden sofort bei login aufgemacht
Nachteil: beim programmieren aufpassen, dass $USER hier nix durch
malformed input exploiten kann (sorry fuers denglish), fuer das
zumachen brauchts wieder sowas wie in 1)

3) festcompiliertes suid-programm, das nur die noetigen iptables
kommandos absetzt und keinen User-input entgegen nimmt.
Vorteil: siehe 2)
Nachteil: siehe 2, falls user-input noetig. Zum aufraeumen brauchts
auch wieder was wie in 1)

etc. (mir faqellt grad nix weiter ein)

HTH,
Juergen
--
Juergen P. Meier - "This World is about to be Destroyed!"
end
If you think technology can solve your problems you don't understand
technology and you don't understand your problems. (Bruce Schneier)
.



Relevant Pages

  • RE: ssh alternatives
    ... You can run ssh on 2 different ports and block one interface totally ... with iptables. ... separate interfaces.. ...
    (RedHat)
  • Firewall Configuration in Redhat 9.0
    ... I've been having some trouble opening and closing ports. ... redhat-config-securitylevel is set to medium. ... nothing is checked except ssh and dhcp. ... I have iptables service enabled. ...
    (RedHat)
  • Re: sshd brute force attempts?
    ... I think you misunderstood what I meant by public service, or maybe it wasn't clear: By a public service I mean a service available for anyone, even anonymously: You're not going to register the world to let people send mail to your server, require authentication to send mail from your server). ... If this is stored on a usb-stick the user carries with him, or only on systems that require local authentication first, then I think you're better off than password based ssh. ... Cracklib is in ports and easy to build -- FreeBSD could use a) an option in make.conf to prevent passwd from getting built on a buildworld and b) the patched passwd/yppasswd tree in ports. ... I don't assume that level of savvy. ...
    (freebsd-questions)
  • Re: Prot Forwarding
    ... Al's SSH method would be the best. ... configure the remote control programs to use different ports on each ... that let you configure the ports in use. ... > Personally I use a Secure Shell tunnel to access multiple XP Pro ...
    (microsoft.public.windowsxp.network_web)
  • Re: is it rational to close the 139 port
    ... You use iptables to reject all connections. ... the services on ports 22 and 80 become unavailable, ... Aptitude in particular will install extra packages that you don't need or want. ... Maybe you are running World of Warcraft under WINE, and installing it opens up port 3724. ...
    (Debian-User)