Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

SSH Tipps+Tricks Server: Netcat, inetd, Apache, Mail, Samba, Mysql, NFS Franz Schäfer LV Linux: Effiziente Anwendung an Hand von Fallbeispielen.

Ähnliche Präsentationen


Präsentation zum Thema: "SSH Tipps+Tricks Server: Netcat, inetd, Apache, Mail, Samba, Mysql, NFS Franz Schäfer LV Linux: Effiziente Anwendung an Hand von Fallbeispielen."—  Präsentation transkript:

1 SSH Tipps+Tricks Server: Netcat, inetd, Apache, Mail, Samba, Mysql, NFS Franz Schäfer LV Linux: Effiziente Anwendung an Hand von Fallbeispielen

2 Franz Schäfer ● Sysadmin @ I.S.T. Austria ● Sysadmin @ ZID WU ● ISP (akis, silverserver,...) ● Nachtrichtentechnik, Regelungstechnik, Computertechnik ● Linux User seit 1995 (kernel 1.1.18)

3 Themenübersicht ● Advanced SSH ● Inetd, netcat, tcpwrapper ● Apache Webserver ● Mailserver Grundlagen ● mysql ● samba übersicht ● NFS

4 Wozu SSH? ● für – terminal verbindung – file transfer – remote execution, automatisierung ● verschlüsselte verbindung – sichert nicht vor: ● kompromitierten eigenen hosts ● kompromitierten fremden hosts

5 Übersicht SSH ● Implementierungen – openssh – putty –... ● remote einloggen mit ssh – mit passwort – mit kerberos ticket – mit RSA/DSA key

6 password login mit ssh # ssh h7788999@login.wu-wien.ac.at The authenticity of host 'login.wu- wien.ac.at (137.208.3.70)' can't be established. RSA key fingerprint is a2:61:d0:f8:1a:13:f7:71:51:26:b8:c2:5f:6 f:00:97. Are you sure you want to continue connecting (yes/no)?

7 ssh mit kerberos # kinit h7788999 # ssh -K h7788999@pecuchet... -K.... Enables forwarding (delegation) of GSSAPI credentials to the server.

8 ssh mit.k5login ● Mit einem file.k5login im homverzeichniss: einlogen mit speziellen kerberos principals moeglich: user2@WU-WIEN.AC.AT ● z.b. in /root/.k5login user1@WU-WIEN.AC.AT user2@WU-WIEN.AC.AT

9 man in the middle ssh irgendwohin @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the- middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is 90:9c:46:ab:03:1d:30:2c:5c:87:c5:c7:d9:13:5d:7

10 scp – secure copy # echo bla >bla.txt # scp bla.txt h7788999@login # scp jemand@irgendwo.at:bla. # scp -r diplomarbeit/ h7788999@login:

11 ssh configuration ●.ssh/config Host wu HostName pecuchet.wu-wien.ac.at User h7788999 ●.ssh/known_hosts ●.ssh/authorized_keys ● Sitewide: – /etc/ssh/ssh_config – /etc/ssh/sshd_config

12 einlogen mit RSA/DSA key # ssh-keygen (eventuell -f) normalerweise mit passphrase # scp.ssh/id_rsa.pub wu: # cat id_rsa.pub >>.ssh/authorized_keys # ssh -i andererschluessel h778899@wu alternativ: # ssh-copy-id wu

13 remote execution ssh user@wu "ls -l /tmp" echo bla | ssh user@wu \ "cat - > bla.txt" ssh user@wu "ls -l /tmp" | grep bla nützlich für scripts zum automatisieren von abläufen

14 Remote Ausführung einschränken ● im.ssh/authorized_keys from="137.208.77.7",no-pty,no-port- forwarding,command="/root/bla.sh" ssh-dss AAAUH7T9Y....

15 X11 forwarding # ssh -X user@woanders # echo $DISPLAY # localhost:10.0 # xterm & # xauth list Achtung: Remote Angreifer bekommt zugriff aufs lokale display

16 ssh agent ssh-agent kann zugriff auf passphrase cachen # ssh-agent xterm & # ssh-add.... passphrase ● Bei vielen Distributionen: ssh-agent wird automatisch mit X gestartet

17 ssh port forwarding # ssh \ -L 3333:proxy.wu-wien.ac.at:8080 \ h778899@login ● von lokal erlauben den wu proxy auf localhost port 3333 zu verwenden (optional: -g ) # ssh -R 4567:localhost:80 \ h778899@login ● zugriff auf den lokaeln webserver von remote host aus erlauben (default: nur von da)

18 ssh socks proxy # ssh -D 9999 h7788999@login ● socks proxy ● z.B.: via browser verwendbar

19 sftp://user@host URL in KDE und GNOME

20 Zusammenfassung SSH ● SSH – mit passwort – mit kerberos – mit RSA Keys – scp – konfiguration – remote kommandos – keys einschränken – X11 Forwarding – port forwarding – agent – eingebauter Socks-Proxy – sftp in KDE/GNOME

21 netcat # apt-get install netcat # echo bla bla| netcat -l -p 7777 telnet localhost 7777

22 inetd – der alleskönner ● im /etc/inetd.conf pop-3 stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.pop3d Beispiel Proxy: 4567 stream tcp nowait nobody /usr/sbin/tcpd /bin/nc -t 192.168.1.1 80 # killall -HUP inetd

23 Excurs TCP wrapper ● Services schützen via: – /etc/hosts.allow – /etc/hosts.deny ● Beispiel: ALL:127.0.0.1,192.168.0.0/255.255.255.0 man hosts_access

24 Apache Webserver ● Marktanteil ca 67% ● Vergleich IIS ca 17% (von 1 million busiest sites, Aug 2020) http://news.netcraft.com/archives/2010/08/11/augus t-2010-web-server-survey-4.html

25 Zugriff auf Webserver # telnet www.wu.ac.at 80 GET / # telnet www.wu.ac.at 80 HEAD / HTTP/1.1 HTTP/1.1 400 Bad Request Date: Wed, 05 Dec 2007 12:38:35 GMT Server: Apache Connection: close Content-Type: text/html; charset=iso-8859-1 # wget -S http://www.wu.ac.at

26 Apache Installieren, Start/Stop # apt-get install apache oder # apt-get install apache2 # apachectl configtest # apache2ctl configtest # apachectl restart # /etc/init.d/apache2 restart

27 Apache Configuration ● /etc/apache2/httpd.conf ● /etc/apache/httpd.conf ● manches auch in.htaccess ● weitere files via Include /etc/apache2/bla/*.conf

28 Apacheconfig Bereiche ● Sitewide – z.B.: Listen 80 – DocumentRoot /var/meinwww/ ● VirtualHost ● Directory ● Location

29 Excurs: Einfaches HTML ● z.B.: index.html test überschrift test fett

30 VirtualHost Name/IP-Based ServerAdmin webmaster@meinserver.at DocumentRoot /var/www/meinserver/ ServerName www.meinserver.at ServerAlias meinserver.at php_flag register_globals 0 RedirectPermanent /w/ http://wuw.at/bla/

31 Beispiel: Directory AllowOverride AuthConfig Options +ExecCGI -Indexes Addhandler cgi-script.cgi ScriptAlias /cgi/ /var/www/scripts/

32 Beispiel Location SetHandler server-status Order Deny,Allow Deny from all Allow from 127.0.0.1 Allow from 123.45.67.89

33 Apache SSL (https://) SSLEngine on SSLCertificateFile /etc/cert/mein.crt SSLCertificateKeyFile /etc/cert/mein.key ServerName meinserver.at DocumentRoot /var/www-secure Problem mit name-based VirtualHosts Keys mit openssl erzeugen

34 Einschub: Keys mit openssl # openssl req -new -nodes \ -newkey rsa:1024 -keyout mein.key \ -out mein.csr # openssl x509 -req -in mein.csr \ - signkey mein.key -out mein.crt \ - days 365 ● zur kontrolle: # openssl rsa -in mein.key -text # openssl req -in mein.csr -text # openssl x509 -in mein.crt -text

35 Offizielle Zetrifizierung ● Verisign, Thawte, & Co... ● TCS Terena (aconet) ● Kostenlose Peer2Peer Zertifizierung: www.cacert.org

36 Einfaches CGI script ● im file: test.cgi #!/bin/bash echo Content-type: text/plain echo echo ich bin: id echo datum ist: date

37 Ein einfaches PHP script

38 Sicherheit 1.) Updaten 2.) Oft Updaten 3.) Regelmäßig Updaten 4.) Achtung bei Scripts 5.) Achtung bei PHP Scripts! 6.) Forum/CMS/Fertigpakete: Updaten!

39 Beispiel PHP Insecurity ● http://www.devshed.com/c/a/PHP /PHP-Security-Mistakes/ include('vorlagen/'. $template) ● $template – aus formular? – aus cookie? ● $template=“../../../../etc/passwd“

40 Beispiel SQL Injection ● $res= mysql_query( 'SELECT * FROM bla WHERE id="'. $_GET['id']. '"'); ● möglicher Inhalt von 'id': ● "; DELETE FROM bla != "dfssdf ● "; DROP DATABASE meinforum;

41 Zusammenfassung Apache – webzugriff per telnet GET / – apache start stop, configtest – wichtige config files – Gültigkeits- bereiche der Direktiven – einfches HTML – Name vs. IP Based VirtualHosts – Directory – Location – https, openssl, Zertifizierung – cgi, php, und Sicherheit

42 Mail Server Grundlagen ● Transport via SMTP: Store and Forward ● Abfrage von Mailboxen: – lokal: /var/spool/mail – POP3 – IMAP ● Hauptproblem: SPAM

43 Übersicht: MTA ● sendmail: alt aber gut ● exim: klein aber fein ● postfix: der herausforderer ● qmail: hauptsache anders

44 Eine Verbindung mit einem Mailserver # telnet mx1.wu-wien.ac.at 25 220 mx1.wu-wien.ac.at ESMT.. helo. mail from: fs@mond.at rcpt to: mond@wu-wien.ac.at data bla. quit

45 IMAP Server ● courier – für mittlere installationen – maildir format ● cyrus – für große installationen ● uw-imapd – standard mbox

46 Commandline Mail # echo test | \ mutt -s test xx@mond.at # mutt -f imaps://h7788999@sslmail.wu-wien.ac.at

47 sendmail config Übersicht ● im Directory /etc/mail/ ● in sendmail. mc (o.ä) ● file editieren # make # make restart

48 nützliches für.mc file (m4) MASQUERADE_AS(`blabla.at')dnl FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl FEATURE(`genericstable', `hash -o /etc/mail/genericstable.db')dnl FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl FEATURE(access_db)dnl define(`SMART_HOST', `smtp.wu- wien.ac.at')

49 mysql ● ca 10 million installations (2008) ● wartungsfrei und robust ● inzwischen fast alle features der grossen

50 mysql commands # mysqladmin -uroot -p create bladb # mysqldump -uroot -p otherdb >other.dump # cat other.dump | mysql -uroot -p bladb # echo "select * from blatable;" \ | mysql -uroot -p bladb

51 mysql prompt am mysql prompt: # CREATE USER 'anna'@'localhost'; # SET PASSWORD FOR 'anna'@'localhost' = PASSWORD('geheim'); # GRANT SELECT ON bladb.* TO 'anna'@'localhost' ;

52 Samba Linux Server für Windows Netze ● apt-get install samba ● datei: /etc/samba/smb.conf /etc/init.d/samba restart [musik] comment = meine mp3sammlung als share writable = no locking = no path = /extraplatte/mp3/ public = yes hosts allow = 192.186.0.0/255.255.0.0

53 NFS Server # /etc/exports: the access control list for filesystems which may be exported /home/ gss/krb5i(rw,sync,fsid=0,no_subtree_check) /home/ 10.11.12.13(rw,no_subtree_check)

54 NFS Client in /etc/fstab: meinserver:/ /nfs4home/ nfs4sec=krb5i0 3

55 weitere bliebte serverdienste ● asterisk (telefonie, sip, h323, isdn..) ● nagios (network monitoring) ● small services (dns, dhcp, tftp, time,...) ● ftp (vsftpd) ● terminal services (X11) ● authentisierung und directory: kerberos, ldap ● virtualisierung (vmware, xen, kvm, openvz, linux-vserver) ● postgres, andere datenbanken ● cluster: gridengine ● IRC, etc..etc..

56 Zusammenfassung ● Advanced SSH ● netcat ● inetd ● tcpwrapper ● Apache Grundlagen ● Mail Server Übersicht ● Einblick in Samba


Herunterladen ppt "SSH Tipps+Tricks Server: Netcat, inetd, Apache, Mail, Samba, Mysql, NFS Franz Schäfer LV Linux: Effiziente Anwendung an Hand von Fallbeispielen."

Ähnliche Präsentationen


Google-Anzeigen