Showing posts with label Fedora. Show all posts
Showing posts with label Fedora. Show all posts

Tuesday, February 11, 2014

Sendmail with DKIM on Fedora 19


http://www.ipsure.com/blog/2010/domainkeys-identified-mail-dkim-with-postfix-smtp-only/
http://www.techsneeze.com/deploy-dkim-milter-multiple-domains-centos-5-sendmail
http://www.cesafaci.ro/tutoriale/sendmail-cu-dkim-pe-centos-fedora-19.html

yum install dkim-milter


cd /etc/mail/dkim-milter/keys
dkim-genkey -r -d your-domain.com
= > 2 files : public key (default.txt) and private key (default.private)

At this point you should have a "default.private" and "default.txt" file in your current working directory (which is /etc/mail/dkim-milter/keys). 
default.txt contains the DNS TXT record you must add to your DNS entries. 

cat default.txt >> /var/named/chroot/var/named/yourdomain.zone
mv default.private /etc/mail/dkim-milter/domeniultau_default.key.pem
chown dkim-milter:dkim-milter /etc/mail/dkim-milter/domeniultau_default.key.pem



/etc/mail/dkim-milter/dkim-filter.conf


Domaindomeniu.ro
KeyFile/etc/mail/dkim-milter/domeniultau_default.key.pem
MTAMSA
Selectordefault
SignatureAlgorithmrsa-sha1
Socketlocal:/var/run/dkim-milter/dkim-milter.sock
SyslogYes
X-HeaderYes












/etc/mail/sendmail.mc
dnl # dkim - yahoo domainkeys implementation
INPUT_MAIL_FILTER(`dkim-filter', `S=local:/var/run/dkim-milter/dkim-milter.sock')

cd /etc/mail
make
service named reload
service dkim-milter start
service sendmail restart
chkconfig dkim-milter on






 The config file (/etc/mail/dkim-milter/dkim-filter.conf) is fully self-documented and easy to understand. 
I made the following changes from the default config:
AutoRestart  Yes
AutoRestartRate 10/1h
Canonicalization simple/simple
Domain  techsneeze.com
ExternalIgnoreList /etc/mail/dkim-milter/trusted-hosts
InternalHosts /etc/mail/dkim-milter/InternalHosts.txt
LogWhy  yes
On-Default accept
On-BadSignature accept
On-DNSError accept
On-InternalError accept
On-NoSignature accept
On-Security accept
SignatureAlgorithm rsa-sha256
Socket  local:/var/run/dkim-milter/dkim-milter.sock
Syslog  yes
SyslogSuccess yes
UserID  dkim-milter:dkim-milter
X-Header  yes



PROBLEM : 
if in the logs appear something like : "no signature data" 
       [ cat /var/log/maillog | grep "no signature data" ] or 
   "external host [192.168.101.54] attempted to send as yourdomain.com
  and this host  [192.168.101.54] is on your internal network ...
SOLUTION: 
#cd /etc/mail/dkim-milter/ 
#touch InternalHosts.txt 
# chmod 444 InternalHosts.txt
 # vi InternalHosts.txt 
         192.168.101.0/24
   
          yourdomain.com     
          smtp.yourdomain.com

~ ~ ~ 

We may enhance DKIM TXT entries like: 
 _domainkey.(yourdomain.com). IN TXT "t=y; o=~; r=postmaster@(yourdomain.com)" 
 where 
 t=y means “this domain is currently testing DKIM, verifier side mustn’t treat the messages differently from unsigned e-mails even if the signature fails to be verified”

 

 o=~ means “some e-mails from this domain are signed, some are not”

  

o=- means “all e-mails from this domain are signed”

 

 r=postmaster@(yourdomain.com) designates responsible e-mail address



When we implemented DomainKeys Identified Mail (DKIM) with Postfix on FreeBSD, we had used dkim-milter plugin. However, it seems that dkim-milter has expired and recently it has been removed from the ports tree. Consequently, we’ll also move to OpenDKIM which is in fact claimed to be bug free compared to dkim-milter. - See more at: http://www.ipsure.com/blog/2012/dkim-milter-is-no-longer-available-how-to-use-opendkim-instead/#sthash.UraBfaka.dpuf





Open



DKIM includes a cryptographic hash in the e-mail header which is calculated with the private key (on the server) and verified with the public key (in the DNS record).
DKIM-Signature: v=1; a=rsa-sha256; d=example.net; s=brisbane;
     c=relaxed/simple; q=dns/txt; l=1234; t=1117574938; x=1118006938;
     h=from:to:subject:date:keywords:keywords;
     bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=;
     b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ
              VoG4ZHRNiYzR


First, install opendkim.
yum install opendkim

/etc/opendkim.conf.
AutoRestart             Yes
UMask                   002
Syslog                  yes
AutoRestartRate         10/1h
Canonicalization        relaxed/simple
ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
InternalHosts           refile:/etc/opendkim/TrustedHosts
KeyTable                refile:/etc/opendkim/KeyTable
LogWhy                  Yes
Mode                    sv
PidFile                 /var/run/opendkim/opendkim.pid
SignatureAlgorithm      rsa-sha256
SigningTable            refile:/etc/opendkim/SigningTable
Socket                  inet:8891@localhost
SyslogSuccess           Yes
TemporaryDirectory      /var/tmp
UserID                  opendkim:opendkim
As you can see, there are three more files to be added, TrustedHosts (whitelisted IPs that can sign e-mails), KeyTable (multiple domain configuration for public and private keys) and SigningTable (whitelisted users that can sign e-mail).

/etc/opendkim/TrustedHosts:
127.0.0.1
example.com
192.168.0.1/24


/etc/opendkim/SigningTable:
*@example.com default._domainkey.example.com
All users from @example.com can sign. You can specifiy usernames and domains, instead of the wildcard, for additional security.

/etc/opendkim/KeyTable:
default._domainkey.example.com example.com:default:/etc/opendkim/keys/example.com.pvt
Location of the private key and name of the DNS record for each domain. The "default" before _domainkey.example.com and :default: is a selector. This can be changed to something else.

Next, we need to generate the public and private key for each domain.
If some folders don't exist, just create them.
# opendkim-genkey -D /etc/opendkim/keys/example.com -d example.com -s default
Again -s flag is for the selector. If you changed it, you need to enter it here.
The command generates a private key (default) and public key (default.txt). You will probably rename them, to match the configuration.
An important note here is that the files are owned by user opendkim, or you will get permission denied errors in /var/log/mail.err. Default permissions on those files are -rw------.

Move the private key to where you specified it should be in the KeyTable.
Insert the public key in your DNS as a TXT record.

Next up, telling sendmail to talk to opendkim.
Edit /etc/mail/sendmail.mc and add this line at the end. 
INPUT_MAIL_FILTER(`opendkim', `S=inet:8891@localhost')

Rebuild sendmail configuration and restart, start opendkim if it's not running yet
service sendmail restart; service opendkim start

Friday, January 24, 2014

openssl , httpd : main process exited - FAILURE




[root@abxrds ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service
Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
[root@abxrds ~]# 




[root@abxrds ~]# 
[root@abxrds ~]# cat /var/log/messages | grep httpd


Jan 24 18:04:40 abxrds httpd[8543]: AH00557: httpd: apr_sockaddr_info_get() failed for www.abxrds.com
Jan 24 18:04:40 abxrds httpd[8543]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Jan 24 18:04:40 abxrds httpd[8543]: httpd (no pid file) not running
Jan 24 18:04:40 abxrds systemd[1]: Unit httpd.service entered failed state.
Jan 24 19:03:37 abxrds systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE


With httpd most errors are also likely to have been sent to /var/log/httpd/error_log at the same time that they were sent to the console.

There were no virtual host configurations !
After creating "www.abxrds.com" virtual host : 


[root@abxrds httpd]# 
[root@abxrds httpd]# journalctl -xn

-- Logs begin at Mon 2014-01-20 22:52:49 EET, end at Fri 2014-01-24 22:04:17 EET. --
Jan 24 22:03:31 www.abxrds.com dbus[521]: [system] Activating service name='org.freedesktop.PackageKit' (using servicehelper)
Jan 24 22:03:31 www.abxrds.com dbus-daemon[521]: dbus[521]: [system] Successfully activated service 'org.freedesktop.PackageKit'
Jan 24 22:03:31 www.abxrds.com dbus[521]: [system] Successfully activated service 'org.freedesktop.PackageKit'
Jan 24 22:04:17 www.abxrds.com systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has begun starting up.
Jan 24 22:04:17 www.abxrds.com httpd[11120]: httpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.modules.d/10-php
Jan 24 22:04:17 www.abxrds.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 24 22:04:17 www.abxrds.com httpd[11122]: httpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.modules.d/10-php
Jan 24 22:04:17 www.abxrds.com systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 24 22:04:17 www.abxrds.com systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
-- 
-- Unit httpd.service has failed.
-- 
-- The result is failed.
Jan 24 22:04:17 www.abxrds.com systemd[1]: Unit httpd.service entered failed state.
[root@abxrds httpd]# 

Line 6 of "/etc/httpd/conf.modules.d/10-php" = "LoadModule php5_module modules/libphp5.so"


httpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: 
Syntax error on line 6 of /etc/httpd/conf.modules.d/10-php.conf: 
Cannot load modules/libphp5.so into server


THE SOLUTION TO THE PROBLEM : 

It's because openSSL hasn't been updated : 
yum update openssl


Saturday, December 21, 2013

Rsync + SSH - no password




Install rsync
For Ubuntu or Debian
# apt-get install rsync
For SUSE or Fedora# yum install rsync
rsync without prompting for password:
Assuming the file server is ServerF and backup server is ServerB

Genarate the public key in ServerF
$ ssh-keygen
$ Enter passphrase (empty for no passphrase):
$ Enter same passphrase again:

The public key will be generated and stored in
~/.ssh/id_rsa.pub

Copy public key to remote host
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.100
Or
ssh-copy-id -i ~/.ssh/id_rsa.pub "root@192.168.1.100" -p123
Or

Open id_rsa.pub, copy the content
Login to ServerB using the same user in the rsync command
In ServerB, append the contents to ~/.ssh/authorized_keys. Create the file if not exist. Make sure the file mode is 700.

Is it possible to run ssh-copy-id on port other than 22?
Rsync with SSH without prompting for password

Saturday, December 7, 2013

Fedora 19 : S.M.A.R.T. - SMARTd - SMARTctL - SMARTmonTools - gSMARTcontroL




Monitoring Hard Disks with SMART

When a failure is anticipated by S.M.A.R.T., 
the user may choose to replace the drive to avoid unexpected outage and data loss.

Fedora comes with a "smartd" service that will email root if serious problems are detected on disks.

[root@server ~]# yum provides smartd
Loaded plugins: langpacks, refresh-packagekit
smartmontools-6.1-1.fc19.x86_64 : Tools for monitoring SMART capable hard disks
Repo        : fedora
Matched from:
Filename    : /usr/sbin/smartd

smartmontools comes with two programs:
   - smartctl : meant for interactive use
   - smartd   : continuously monitors S.M.A.R.T.


Check smartctl daemon service
   # service smartd status



[root@abxrds ~]# 
[root@abxrds ~]# service smartd status
Redirecting to /bin/systemctl status  smartd.service
smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
   Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled)
   Active: active (running) since Fri 2013-12-06 22:27:46 EET; 2h 30min ago
 Main PID: 9625 (smartd)
   CGroup: name=systemd:/system/smartd.service
           └─9625 /usr/sbin/smartd -n -q never

Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb, type changed from 'scsi' to 'sat'
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], opened
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], ST2000DM001-9YN164, S/N:Z1E2JV3Q, WWN:5-000c50-04f5f87f8, FW:CC4G, 2.00 TB
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], found in smartd database: Seagate Barracuda 7200.14 (AF)
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], WARNING: A firmware update for this drive is available,
Dec 06 22:27:46 abxrds smartd[9625]: see the following Seagate web pages:
Dec 06 22:27:46 abxrds smartd[9625]: http://knowledge.seagate.com/articles/en_US/FAQ/207931en
Dec 06 22:27:46 abxrds smartd[9625]: http://knowledge.seagate.com/articles/en_US/FAQ/223651en
Dec 06 22:27:47 abxrds smartd[9625]: Device: /dev/sdb [SAT], is SMART capable. Adding to "monitor" list.
Dec 06 22:27:47 abxrds smartd[9625]: Monitoring 2 ATA and 0 SCSI devices
[root@abxrds ~]# 

To ensure that your drive supports SMART, type:
smartctl -i /dev/sda 

SMART will also give you a lot of detailed information about the drive : 
smartctl -a /dev/sda

[root@gate ~]# smartctl -a /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.11.6-200.fc19.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate SV35
Device Model:     ST2000VX000-1CU164
Serial Number:    S1E2D65T
LU WWN Device Id: 5 000c50 062131fc0
Firmware Version: CV22
User Capacity:    2,000,398,934,016 bytes [2.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Sat Dec  7 00:38:33 2013 EET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
without error or no self-test has ever 
been run.
Total time to complete Offline 
data collection: (   97) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine 
recommended polling time: (   1) minutes.
Extended self-test routine
recommended polling time: ( 223) minutes.
Conveyance self-test routine
recommended polling time: (   2) minutes.
SCT capabilities:       (0x10b9) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   113   099   006    Pre-fail  Always       -       54914664
  3 Spin_Up_Time            0x0003   095   095   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       43
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   069   060   030    Pre-fail  Always       -       9313921
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       1483
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       43
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0
189 High_Fly_Writes         0x003a   072   072   000    Old_age   Always       -       28
190 Airflow_Temperature_Cel 0x0022   066   065   045    Old_age   Always       -       34 (Min/Max 22/35)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       15
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       43
194 Temperature_Celsius     0x0022   034   040   000    Old_age   Always       -       34 (0 17 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%      1482         -
# 2  Short offline       Completed without error       00%      1478         -
# 3  Short offline       Completed without error       00%        42         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

[root@gate ~]# 


Check the overall health:
smartctl -H /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.11.6-200.fc19.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED



Testing a Drive


You may run any type of test while the drive is mounted although there may be some drop in performance. There are three types of test that can be conducted on a drive:
  1. Short
  2. Extended (Long)
  3. Conveyance
To find an estimate of the time it takes to conduct each test, type:
sudo smartctl -c /dev/sda 

The most useful test is the extended test (long). You can initiate the test by typing:
sudo smartctl -t long /dev/sda 

Results


You can view a drive's test statistics by typing:
sudo smartctl -l selftest /dev/sda 

Suggested application: GSmartControl

[root@gate ~]# yum install gsmartcontrol
Loaded plugins: langpacks, refresh-packagekit
Package gsmartcontrol-0.8.7-2.fc19.x86_64 already installed and latest version