2010-08-06

VSFTPD - how to share network drives

I'm going to describe how to add users to the Linux server where your FTP server runs (vsftpd of course...).
First off log in to the server per SSH, we'll use "server" as server's name and admin as the user with sudo rights (for SSH connections you'll need Putty on windows, Terminal on mac OS X and a normal terminal on Linux).
ssh -Y admin@server

2010-04-25

Cron

If you want to launch script periodically, you'll have to use cron (manual pages are well done). And the ouput of your script, if any, will be sent to the user the cron entry belongs to.

Now i added some script in /etc/cron.daily and i never received any mail from those ones. The user running the script was root, and the script was indeed generating output.

The trick is, you have to specifically add, in the case of /etc/cron.daily, /etc/cron.hourly and the other ones, the following line to your script :

MAILTO=root

if you want the result sent to root (or any other user/email assuming you set a MTA agent with a relayhost on your box, like postfix).

2010-04-22

Postfix - Linux sending emails

Wow ! i did it in the end, getting Postfix to simply send emails ! That shouldn't be that hard, but somehow, i never had the courage to rtfm to the end. Well, first of, the documentation on the Ubuntu Server Guide is somehow lacking for the very simple task i was trying to achieve. Here's the magic recipe !

Note 1: this howto does not intended to set up a POP3/SMTP server, but only to make Ubuntu send emails, nothing else (to get backup log results from different servers i'm administering). It's done using the version 2.6.5-3 of Postfix.

Note 2: you need a valid email account (and preferably not a free one like gmail, but the kind of your ISP gives you), which means you need to know the address of your SMTP server (smtp.myisp.com), and have a pair login:password that fits.

Note 3: if you don't like vi (and especially if you're working locally) feel free to use any text editor, like gedit on Gnome, for instance.

1) Install/upgrade postfix
sudo aptitude install postfix (1)
2) Configure it
sudo dpkg-reconfigure postfix

and set it as follow:

General type of mail configurationSatellite system
System mail namemycomputer.local (2)
SMTP relay hostsmtp.myisp.com (3)
Root and postmaster mail recipientyour unix username (4)
Other destinations to accept mail formycomputer.local (5)
Force synchronous updates on mail queue?No
Local networksleave this blank
Mailbox size limit (bytes)0
Local address extension character+
Internet protocols to useipv4 (6)
3) Edit main.cf
sudo vi /etc/postfix/main.cf

after the line relayhost = smtp.myisp.com add this :

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_generic_maps = hash:/etc/postfix/generic
4) Create/edit sasl_passwd
sudo touch /etc/postfix/sasl_passwd
sudo chmod go-rwx  /etc/postfix/sasl_passwd
sudo vi /etc/postfix/sasl_passwd

add/write the line:

smtp.myisp.com login:password (7)

then:

sudo postmap /etc/postfix/sasl_passwd
5) Create/edit generic
sudo vi /etc/postfix/generic

add/write the line where senderemail is the name you want, this will be used in th "from" field of all emails that will be sent by postfix, the only important thing being that myisp.com is a valid mail domain:

@mycomputer.local senderemail@myisp.com

then:

sudo postmap /etc/postfix/generic
6) Reload postfix and test
sudo postfix reload

To test it, issue this command (sending an email only with the name of the machine):

echo `date` on `hostname`|sendmail myemail@myisp.com

You should receive an email in your myemail@myisp.com inbox account from senderemail@myisp.com. If not, troubleshooting is made easy by looking at: /var/log/mail.log with your favorite text editor/log viewer.

Last thing, if you want to have your local mail forwarded to you, add a /home/user/.forward file in your home directory with the email of your choice (and you can do the same for root, /root/.forward).

Notes
  1. I'll go ahead (yeaah) and pass on the fact that, because of package dependencies -and good ol' logic-, this command could remove something else like exim4, sendmail and other packages that play the same role, that's perfectly ok, if you're the real admin of the machine (ie you know you're not breaking something else). Then again, it could do nothing, or only upgrade because postfix is already there.
  2. Use any name you want ! it can be any fantasy name, since you're not really going to host a mail server...
  3. Your isp's SMTP server of course, mhhhh ?
  4. You're not always root, right ?
  5. Same as System mail name (TODO: add an explanation)
  6. But if you know what you're doing, feel free to say all or ipv6
  7. Don't make me state the obvious