Saturday, May 26, 2012

Exim Commands

Debug a mail delivery:
 exim -bt -d email@address.com 
Retry message delivery:
 exim -M messageID
Force delivery of all message:
 exim -qf
Force delivery of all message and delete of frozen ones:
 exim -qff
Shows log delivery for a message:
 exim -Mvl messageID
Display message body:
 exim -Mvb messageID
Display message header:
 exim -Mvh messageID
Delete a message without warning:
 exim -Mrm messageID
Count messages in queue:
 exim -bpr | grep "<" | wc -l or exim -bpc
Display all messages from queue:
 exim -bp
Count frozen messages:
 exim -bpr | grep frozen | wc -l
Delete frozen messages:
 exim -bpr | grep frozen | awk '{print $3}' | xargs exim -Mrm
 
P.s. You can get some more cool tips from exim cheatsheet 

Saturday, May 12, 2012

Today I needed to set up connections to 2 different ports, running on a machine, sitting behind my firewall.

I knew that I needed to set up a SSH tunnel from my laptop to the server, but I certainly did not want to open 2 different shells each time I wanted to connect to the ports.

Thankfully, the ssh command allows you to specify multiple tunnels through the same server in one command. The command to do this is:

ssh -c arcfour  -C -L 8080:127.0.0.1:8080 -L 8081:127.0.0.1:8081  homedsl.org

Monday, April 23, 2012

Im amazed by how many people don’t know about runlevels, let alone, to identify what runlevel you are in.

To see what runlevel you are in.

who -r
or
/sbin/runlevel


HTH
Brent

P.s. To find out about runlevels

Friday, April 13, 2012

This is more for me, than for anyone. I always seem to forget this command.

If you need to discover from which package a particular program came from, you can use this command.


dpkg -S /usr/bin/ssh
openssh-client: /usr/bin/ssh



HTH
Brent

Wednesday, April 11, 2012

Where I work, we had an interesting request from a client.  This client is a mass mailer. And they wanted a means to self configure exim, for which ip a domain must be listening on.

Heres how I did it.

First we create the router:
vi /etc/exim4/conf.d/router/350_exim4-config_vdom_aliases
vdom_aliases:
      driver = redirect
      allow_defer
      allow_fail
      domains = dsearch;
/path/for/client/mail/virtual
      data = ${expand:${lookup{$local_part}lsearch*@{/path/for/client/mail/virtual/$domain}}}
      retry_use_local_part
      pipe_transport   = address_pipe
      file_transport   = address_file
      no_more


Next we copy the orignal remote_smtp transport
cp /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp  /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp_new

vi  /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp_new

 remote_smtp_new:
  debug_print = "T: remote_smtp for $local_part@$domain"
  driver = smtp
.ifdef REMOTE_SMTP_HOSTS_AVOID_TLS
  hosts_avoid_tls = REMOTE_SMTP_HOSTS_AVOID_TLS
.endif
.ifdef REMOTE_SMTP_HEADERS_REWRITE
  headers_rewrite = REMOTE_SMTP_HEADERS_REWRITE
.endif
.ifdef REMOTE_SMTP_RETURN_PATH
  return_path = REMOTE_SMTP_RETURN_PATH
.endif
.ifdef REMOTE_SMTP_HELO_DATA
  helo_data=REMOTE_SMTP_HELO_DATA
.endif
.ifdef DKIM_DOMAIN
dkim_domain = DKIM_DOMAIN
.endif
.ifdef DKIM_SELECTOR
dkim_selector = DKIM_SELECTOR
.endif
.ifdef DKIM_PRIVATE_KEY
dkim_private_key = DKIM_PRIVATE_KEY
.endif
.ifdef DKIM_CANON
dkim_canon = DKIM_CANON
.endif
.ifdef DKIM_STRICT
dkim_strict = DKIM_STRICT
.endif
.ifdef DKIM_SIGN_HEADERS
dkim_sign_headers = DKIM_SIGN_HEADERS
.endif
interface = ${if exists {
/path/for/client/mail/domainiplist}{${lookup{$sender_address_domain}lsearch*{/path/for/client/mail/domainiplist}{$value}{}}}{}}
helo_data = ${if exists {
/path/for/client/mail/domainhelolist}{${lookup{$sender_address_domain}lsearch*{/path/for/client/mail/domainhelolist}{$value}{$primary_hostname}}}{$primary_hostname}}

Then 

vi  /etc/exim4/conf.d/main/000_localmacros
MAIN_LOCAL_DOMAINS = @:localhost:dsearch;/path/for/client/mail/virtual

Wednesday, April 4, 2012

Create passwords

As an admin, im amazed by the passwords I come across.

Heres a little tool and command to help.

pwgen -Bnyc

-B Don't include ambiguous characters in the password
-n Include at least one number in the password
-y Include at least one special symbol in the password
-c Include at least one capital letter in the password

Add a number to set password length, add another to set how many password to output. Example:

pwgen -Bnyc 12 20
this will output 20 password of 12 chars length.