8 de abril de 2010

Shellinabox over https con apache2 en Debian Lenny


El problema de Firefox 3.6 que no funciona ajaxterm me ha obligado a revisar la instalación del terminal shell over https instaldo en micra.
Y buscando veo una referencia interesante shellinabox over https, que tiene buena pinta aunque ya de entrada tiene algunos errores.

Voy a probarlo ya que es idéntico a la configuración proxy ssl con ajaxterm que tengo actualmente en micra pero redireccionando el tráfico al puerto 4200 de shellinabox. En principio esto debería funcionar sin problemas, aunque habia algun bug con shellinabox y SSL en debian.

La diferencia con los intentos anteriores que hice y que no fucnionaron son:
Vamos con ello:

1) Instalando Shellinbox en Debian Lenny:
# wget http://shellinabox.googlecode.com/files/shellinabox_2.10-1_i386.deb
# dpkg -i shellinabox_2.10-1_i386.deb
2) Apache2 y SSL deben estar instalados y funcionando correctamente.
Redirecconamiento del tráfico en apache2:
/etc/apache2/mods-enabled
ln -s ../mods-available/proxy.conf
ln -s ../mods-available/proxy.load
ln -s ../mods-available/proxy_http.load
3) Editamos el fichero /etc/apache2/sites-available/default-ssl
añadiendo al final el redireccionamiento al puerto 4200 de shellinabox:
<Location /shell>
ProxyPass http://localhost:4200/
Order allow,deny
Allow from all
</Location>


¿¿¿ Solo pone esto en /apache2/sites-available/default-ssl ? ¿¿¿ Y la autentificación e usuarios y el SSL ?, see micra config ajaxterm En fin, sigamos a ver si funciona ...

4) Ahora cambiamos la configuración de shellinabox añadiento la lo resaltado en negrita al archivo /etc/init.d/shellinabox
# Set some default values
SHELLINABOX_DATADIR="${SHELLINABOX_DATADIR:-/var/lib/shellinabox}"
SHELLINABOX_PORT="${SHELLINABOX_PORT:-4200}"
SHELLINABOX_USER="${SHELLINABOX_USER:-shellinabox}"
SHELLINABOX_GROUP="${SHELLINABOX_GROUP:-shellinabox}"
SHELLINABOX_ARGS="--localhost-only --disable-ssl"

5) Reiniciamos apache2 y shellinabox... pudiendo acceder https://localhost/shell/ desde cualquier localización.
# /etc/init.d/apache2 restart
# /etc/init.d/shellinabox restart

RESULTADO:
Desde micra
https://localhost/ me da:
An error occurred during a connection to localhost. Secure Connection Failed
SSL received a record that exceeded the maximum permissible length.
(Error code: ssl_error_rx_record_too_long) The page you are trying to view can not be shown because the authenticity of the received data could not be verified. * Please contact the web site owners to inform them of this problem. Try again
Solucción: Parece un error de la clave, revisar la generación de clave y config de esto.

see: https://www.servertastic.com/support/KB/a36/error-code-ssl-error-rx-record-too-long.aspx

Pruebo a añadir al final del archivo /etc/apache2/sites-available

SetEnvIf Request_URI "^/u" dontlog
ErrorLog /var/log/apache2/error.log
Loglevel warn
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem

ProxyRequests Off

#Quito autenficacion de ajaxterm
#
# AuthUserFile /srv/ajaxterm/.htpasswd
# AuthName EnterPassword
# AuthType Basic
# require valid-user
#
# Order Deny,allow
# Allow from all
#


#cambio lo puertos al de shellinabox

ProxyPass / http://localhost:4200/
ProxyPassReverse / http://localhost:4200/

RESULTADO: mejor!!
Pilla el certificado pero no me deja entrar ...
Forbidden You don't have permission to acces in this server
Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g Server at localhost Port 443
Pruebo a usar los passwords de ajaxterm descomentado las lineas de /etc/apache2/sites-available,
el añadido al fichero
/etc/apache2/sites-available

SetEnvIf Request_URI "^/u" dontlog
ErrorLog /var/log/apache2/error.log
Loglevel warn
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem

ProxyRequests Off


AuthUserFile /srv/ajaxterm/.htpasswd
AuthName EnterPassword
AuthType Basic
require valid-user

Order Deny,allow
Allow from all


ProxyPass / http://localhost:4200/
ProxyPassReverse / http://localhost:4200/

RESULTADO: mejor!, mucho mejor!!
Me pide las calves para entrar, uso las de jaxterm, entro y ...
http://localhost/
micra login:

estamos dentro!!!
micra login: pp
Password:
Last login: Thu Apr 8 21:39:15 CEST 2010 from 127.0.0.1 on pts/10
Linux micra 2.6.32.3-pp01 #1 Sun Jan 10 00:36:54 CET 2010 i586
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
pp@micra:~$
Bingo!!!!, lo tenemos!!!

He comprobado que funciona desde el localhost y desde la red local accediendo desde Firefox 3.6 en https.

Ahora falta la prueba de fuego,
acceder desde un equipo externo ...
...mañana en el curre será un duro día de trabajo!! ;))

No hay comentarios:

Publicar un comentario