Wednesday 29 June 2011

Generate self-signed SSL cert

#!/usr/bin/env python
"""
A self-signed certificate generator.
"""
import os

_name="server"

commands = [
"openssl genrsa -des3 -out %s.key 1024" % _name,
"openssl req -new -key %s.key -out %s.csr" % (_name,_name),
"cp %s.key %s.key.org" % (_name,_name),
"openssl rsa -in %s.key.org -out %s.key" % (_name,_name),
"openssl x509 -req -in %s.csr -signkey %s.key -out %s.crt" % (_name,_name,_name)
]

for c in commands:
os.system(c)

#credit to http://www.akadia.com/services/ssh_test_certificate.html where the information comes from.

#When you run this code, where it asks for Common Name or YourName, enter the name of the host eg - www.example.com or mywebserver.sales.example.com .

#See http://artins.org/ben/how-to-create-a-multihomed-certificate-with-openssl for creating one certificate to protect multiple hosts.

Monday 27 June 2011

Debian Packaging

How I made a .deb file

Create a directory
mkdir foo
Descend into it.
cd foo
Create a directory DEBIAN
mkdir DEBIAN
Descend into it.
Create a text file called 'control'
vim control


The postinst and prerm scripts also go in the DEBIAN directory.
The actual install files go in the foo directory

./foo
./foo/DEBIAN
./foo/DEBIAN/control
./foo/DEBIAN/postinst
./foo/DEBIAN/prerm
./foo/bar.....

Finally, go to the directory above foo and do:

dpkg -b ./foo foo.deb and that is it! done!