mardi 27 décembre 2011

Tips SSH

Pour ajouter un tunnel SSH quand on a oublie de le specifier a la connexion
Depuis le shell,
# ~C
pour ouvrir le menu de ssh puis par exemple, s'il on veut ajouter un forward de notre machine depuis le port 8085 vers la machine 192.168.11.151 port 8084


ssh> -L:8085:192.168.11.151:8084
Forwarding port.


Copier sa cle publique SSH vers un serveur qui n'utilise pas le port 22
Pour copier sa cle publique et ainsi eviter de manipuler des password le plus simple est d'utiliser ssh-copy-id mais la transmettre vers un serveur qui n'ecoute pas sur le port 22 voici un petit truc :

ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 60001 root@172.16.17.100'

jeudi 22 décembre 2011

Apache reverse proxy

Une petite config de Apache comme reverse proxy pour permettre de faire tourner plusieurs sites sur la meme ip sur le meme port.

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName aa.bbb.com
    ServerAlias aaname.bbname.com
    ErrorLog logs/aaa.com.-error_log
    CustomLog logs/aaa.com.co-access_log common
    ProxyPass / http://192.168.1.118/
    ProxyPassReverse / http://192.168.1.118/
</VirtualHost>

 Attention tout de meme, si vous avez un premier site de configurer, disons statique et que vous creer maintenant un virtualhost vous nous pourrez plus acceder au site static. Il faut declarer chacun comme Virtualhost

NameVirtualHost *:80
Le premier site, "static"
<VirtualHost *:80>
        ServerName www.blabla.com
        ServerAlias blabla.com
        DocumentRoot "/var/www/html"
</VirtualHost>
Le second site, le site virtuel qui renvoit vers une autre machine
<VirtualHost *:80>
    ServerName ohohoho.com
    ServerAlias ohohohoh.com
    ErrorLog logs/ohohohoh.com-error.log
    CustomLog logs/ohohohoh.com-access_log common
    ProxyPass / http://192.168.1.121/
    ProxyPassReverse / http://192.168.1.121/
</VirtualHost>

vendredi 16 décembre 2011

Zimbra on OpenVZ

Impossible de faire fonctioner Zimbra 7.1 sur OpenVZ

Des dizainnes d'installation, de "tuning" dans les sens sans rien y faire.
Comme d'hab la seule solution a ete d'etre genereux avec les ressources locales.

Ainsi ca fonctionne :


ONBOOT="yes"
# UBC parameters (in form of barrier:limit)
KMEMSIZE="9223372036854775807:9223372036854775807"
LOCKEDPAGES="10184:10184"
PRIVVMPAGES="9223372036854775807:9223372036854775807"
SHMPAGES="122218:122218"
NUMPROC="5092:5092"
PHYSPAGES="0:9223372036854775807"
VMGUARPAGES="33792:9223372036854775807"
OOMGUARPAGES="26112:9223372036854775807"
NUMTCPSOCK="5092:5092"
NUMFLOCK="1000:1100"
NUMPTY="509:509"
NUMSIGINFO="1024:1024"
TCPSNDBUF="48672085:69528917"
TCPRCVBUF="48672085:69528917"
OTHERSOCKBUF="24336042:45192874"
DGRAMRCVBUF="24336042:24336042"
NUMOTHERSOCK="5092:5092"
DCACHESIZE="45561040:46927872"
NUMFILE="81472:81472"
AVNUMPROC="2546:2546"
NUMIPTENT="200:200"
# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE="100000000:150000000"
DISKINODES="100000000:150000000"
QUOTATIME="0"
# CPU fair sheduler parameter
CPUUNITS="1000"
VE_ROOT="/vz/root/$VEID"
VE_PRIVATE="/vz/private/$VEID"
OSTEMPLATE="ubuntu-10.04-x86_64"
ORIGIN_SAMPLE="vps.basic"
IP_ADDRESS="192.168.1.121"
HOSTNAME="zimbra.x.com"
NAMESERVER="8.8.8.8"

Ca fonctionne meme si bien sur, potentiellement ca peut prendre toutes les ressources.
N'oublier pas de verifier la conf avec vzcfgvalidate.

lundi 12 décembre 2011

Squid authentification LDAP

Configuration de l'authentificacion de Squid avec Active directory Microsoft

On valide la connexion
# Active Directory configuration
auth_param basic program /usr/lib/squid/squid_ldap_auth -R -v 3 -b "dc=foo,dc=corp" -D "cn=Proxy1,cn=Users,dc=foo,dc=corp" -w "xxx" -f sAMAccountName=%s -h 192.168.11.206
auth_param basic children 5
auth_param basic realm Squid Proxy Server
auth_param basic credentialsttl 5 minutes

On authorize un groupe
#ldap authorizations
#full proxy access logger
external_acl_type ldap_group %LOGIN /usr/lib/squid/squid_ldap_group -R \
-b "dc=foo,dc=corp" \
-D "cn=Proxy1,cn=Users,dc=foo,dc=corp" \
-w "xxx" \
-f "(&(objectclass=person)(sAMAccountName=%v)(memberof=cn=%a,cn=users,DC=foo,DC=corp))" \
-h 192.168.11.206

On renvoit vers Squidguard, on pourrait aussi associe des autorizacions par groupe LDAP
#Squidguard
redirect_program /usr/bin/squidGuard -c /etc/squid/squidguard.conf

########################
####### acls locales####
########################
acl manager proto cache_object
#acl all src 0.0.0.0/0.0.0.0
acl to_localhost src 127.0.0.1/32
acl localhost dst 127.0.0.0/8
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 8522 # otros ssh
acl Safe_ports port 22
acl CONNECT method CONNECT
acl ldap-group proxy_auth REQUIRED
#acl redlocal src 192.168.10.0/23
acl Proxy external ldap_group ProxyFULL


########################
####### Restricciones###
########################
http_access allow Proxy
http_access allow Accesorestringido
http_access deny manager
http_access allow MonarcaTestProxy
http_access deny !Safe_ports
http_access allow manager localhost
http_access deny CONNECT !SSL_ports
http_access allow localhost

http_access deny all

icp_access allow all
http_port 3128 transparent
hierarchy_stoplist cgi-bin ?
access_log /var/proxy/log/access.log squid
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
acl apache rep_header Server ^Apache
#broken_vary_encoding allow apache
coredump_dir /var/spool/squid
visible_hostname [My HOSTNAME]


Commande utile pour verifier l'appartenance 
C:\Windows\system32>dsget USER "CN=foouser,OU=foo,DC=foo,DC=corp" -memberof

Commande Squid pour tester le proxy
squidclient -h 127.0.0.1 -u user -w password http://sysadmin10.blogspot.com

vendredi 9 décembre 2011

Probleme pour mettre a jour Debian 5.0 vers Debian 6.0

Lors du passage de Debian 5.0 Lenny a Debian 6.0 Squeeze
Erreur d'update

Reading package lists... Done
W: GPG error: http://backports.debian.org squeeze-backports Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
W: GPG error: http://security.debian.org squeeze/updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
W: GPG error: http://ftp.us.debian.org squeeze Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
W: GPG error: http://ftp.us.debian.org squeeze-proposed-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
W: You may want to run apt-get update to correct these problems


solution
Importer la cle publique depuis internet.

apt-key adv --recv-keys --keyserver subkeys.pgp.net AED4B06F473041FA; gpg --export --armor AED4B06F473041FA | apt-key add -