Things you rarely do
Contents |
... that are difficult to remember
Create an ssh key (and upload it to a server)
Prerequisites
- The SSH client package (openssh-client on debian and ubuntu)
- Decide on the type of key (RSA or DSA)
Which type of key to use can be discussed endlessly, here are some key considerations:
- DSA is faster in signing, but slower in verifying (compared to RSA)
- DSA keys must be exactly 1024 bits as specified by FIPS 186-2 while RSA keys can be anything from 768 bits and upwards (2048 is the default)
- See the following mailing list thread for further discussion: http://leaf.dragonflybsd.org/mailarchive/users/2005-01/msg00140.html
Creating the key pair
The keys must be created on the machine which you ssh from. To generate an RSA key:
ssh-keygen -t rsa -b 2048
To generate a DSA key:
ssh-keygen -t dsa
The command will ask you where to save the files. The default is a sane location.
Uploading the public key to the server
If you used the default location:
ssh-copy-id SERVER
If you saved it in a non-default location:
ssh-copy-id -i FILE SERVER
Create an svn repository and start using it via ssh
Server-side setup
Legend:
- REP: name of the directory containing the repository
- REPUSER: name of the system user that has access to the repository
Do the following to create the repository
sudo svnadmin create /var/svn/REP sudo chown -R REPUSER:REPUSER /var/svn/REP
Client-side
Legend:
- LOCAL_REP: location of the repository checkout
- HOST: address of the server
cd LOCAL_REP mkdir trunk/ tags/ branches/ svn import . svn+ssh://REPUSER@HOST/REP svn co svn+ssh://REPUSER@HOST/REP/ .
If you don't want to have the tags/ and branches/ directories in your checkout directory, do the following:
rm -rf LOCAL_REP/* cd LOCAL_REP svn co svn+ssh://REPUSER@HOST/REP/trunk/ .
Change the URL of an SVN repository
Legend:
- OLD_URL: Current URL of the repository, can be fetched from the 'svn info' command
- NEW_URL: The new URL
svn switch --relocate OLD_URL NEW_URL
SVN branching and merging
This website explains it in an excellent way: http://www.math-linux.com/spip.php?article118
Create a .htaccess/.htpasswd file for Apache HTTP Auth.
To create, simply run:
htpasswd -c FILENAME USERNAME PASSWORD
Update .htaccess/.htpasswd
All you have to run is:
htpasswd FILENAME USERNAME PASSWORD
If you'd rather be prompted for the password, pass the -b option to htpasswd.
Extract pages from a PDF
To create a new pdf file outfile.pdf containing pages 5-8 from inputfile.pdf:
Using pdftk:
pdftk A=inputfile.pdf cat A5-8 output outfile.pdf
Using ghostscript:
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-dFirstPage=5 -dLastPage=8 \
-sOutputFile=outfile.pdf inputfile.pdf