SSH host based authentication

Genereer een key pair:

[username@fromhost ~]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_dsa.
Your public key has been saved in /home/username/.ssh/id_dsa.pub.
The key fingerprint is:
75:ed:f7:06:00:02:65:3e:4d:7b:fb:cf:4c:59:fc:63 username@fromhost

Kopieer public key naar de remote host:

[username@fromhost ~]$ scp .ssh/id_dsa.pub username@tohost:/home/username/
Password:
id_dsa.pub               100% 1131     1.1KB/s   00:00

Voeg de public key toe aan de lijst met geauthorizeerde keys:

username@tohost$ cat id_dsa.pub >> .ssh/authorized_keys

Zorg dat je .ssh directory en de lijst met keys niet world-readable zijn:

username@tohost$ chmod 600 .ssh/authorized_keys
username@tohost$ chmod 700 .ssh

SMTP authenticatie

AUTH PLAIN

$ perl -MMIME::Base64 -e 'print encode_base64("\000username\000password");'
AHVzZXJuYW1lAHBhc3N3b3Jk
$ telnet smtphost 25
Trying 18.67.13.317
Connected to smtphost.
Escape character is "^]".
220 Domain.com SMTP Server
HELO mailserver
250 smtp.domain.com
AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk
235 Authentication successful

AUTH LOGIN

$ perl -MMIME::Base64 -e 'print encode_base64("username");'
dXNlcm5hbWU=
$ perl -MMIME::Base64 -e 'print encode_base64("password");'
cGFzc3dvcmQ=
$ telnet smtphost 25
Trying 18.67.13.317
Connected to smtphost.
Escape character is "^]".
220 Domain.com SMTP Server
HELO mailserver
250 smtp.domain.com
AUTH LOGIN
334 VXNlcm5hbWU6
dXNlcm5hbWU=
334 UGFzc3dvcmQ6
cGFzc3dvcmQ=
235 Authentication successful

Let op: Gebruik geen echo in plaats van printf; echo stuurt n !

IMAP authenticatie

LOGIN

$ telnet imaphost 143
Trying 18.67.13.317...
Connected to imaphost.
Escape character is "^]".
* OK
01 LOGIN username password
01 OK Logged in.

AUTHENTICATE PLAIN

$ perl -MMIME::Base64 -e 'print encode_base64("\000username\000password");'
AHVzZXJuYW1lAHBhc3N3b3Jk
$ telnet imaphost 143
Trying 18.67.13.317...
Connected to imaphost .
Escape character is '^]'.
* OK
01 AUTHENTICATE PLAIN
+
AHVzZXJuYW1lAHBhc3N3b3Jk
01 OK Logged in.