12/23/2014

How to make send only sendmail server.

I have a EC2 instance in AWS. I configured my sendmail to send only for some purpose. Here is how. Let's say the your servers are in the subnet of 10.0.1.0/24 and the IP address of the relay server is 10.0.1.25.

1. Allow relay from your VPC in /etc/mail/access

--access--
[root@host /]# cd /etc/mail
[root@host /]# cp access access.org
[root@host /]# cp access.db access.db.org
[root@host /]# vi access
===
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
Connect:10.0                            RELAY  <-- Add
===
[root@host /]# makemap -v hash access.db < access

--submit.mc--
[root@host /]# cp submit.mc submit.mc.org
[root@host /]# cp submit.cf submit.cf.org
[root@host /]# vi submit.mc
===
define(`confDOMAIN_NAME', `yourdomain.com')dnl  <-- Add
FEATURE(`msp', `[10.0.1.25]')dnl  <-- Change to your relay server.
===
[root@host /]# m4 submit.mc > submit.cf

--sendmail.mc--
[root@host /]# cp sendmail.mc sendmail.mc.org
[root@host /]# cp sendmail.cf sendmail.cf.org
[root@host /]# vi sendmail.mc
===
define(`SMART_HOST', `[10.0.1.25]')dnl  <-- Add
define(`MAIL_HUB', `yourdomain.com.')dnl  <-- Add
define(`LOCAL_RELAY', `yourdomain.com.')dnl  <-- Add
===
[root@host /]# make sendmail.cf
[root@host /]# service sendmail restart

That's it!
Then test it from your web server.





12/10/2014

How to create mysql user on Amazon RDS


When I created a new mysql user on RDS, I got the following error.

===
ERROR 1184 (08S01): Aborted connection  to db: 'unconnected' user:  host:  (init_connect command failed)
===
After googling a while, the cause looks that I changed the timezone of the RDS from UTC to JST.

I got around the issue by the following commands. I need to grant execute command to mysql DB to a new mysql user.


mysql> grant execute on mysql.* to 'some_user'@'%';
mysql> grant select on some_db.some_table to 'some_user'@"%";
mysql> flush privileges;
mysql> set password for 'some_user'@'%' = password('some_pass');

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| some_db            |
| mysql              |
+--------------------+
3 rows in set (0.00 sec)
Now it works, :) even though I don't like the new mysql user to access information schema and mysql db.