All posts by James Lawton

I am a big nerd.

Configute Samba Active Directory Domain Controller. (Centos)

The Samba package provided from official repository does not provide the DC function yet, so Download Samba RPM package from the EnterpriseSAMBA.com ( http://enterprisesamba.com/ ) which is introduced by Samba official site ( https://www.samba.org/ ).
[1]
Register your user info on the site below first to download Samba RPM package.
https://portal.enterprisesamba.com/
[2]
After registration, access to the URL above again and click ‘Login’ to login the site.
[3]
After login, remember your username and accesskey which is displayed on the site. It’s necessarry to set in repo file for yum later.
[4]
Scroll down the page and download ‘sernet-samba-4.1.repo’ for CentOS 7 to your PC or server. Next, upload it to the server you will install Samba4 and move it under the ‘/etc/yum.repos.d’.
[5] Set your username and accesskey in repo file.
[root@smb ~]# vi /etc/yum.repos.d/sernet-samba-4.1.repo
# change to your username and accesskey
[sernet-samba-4.1]
name=SerNet Samba 4.1 Packages (centos-7)
type=rpm-md
baseurl=https://USERNAME:ACCESSKEY@download.sernet.de/packages/samba/4.1/centos/7/
gpgcheck=1
gpgkey=https://USERNAME:ACCESSKEY@download.sernet.de/packages/samba/4.1/centos/7/repodata/repomd.xml.key
enabled=1
[6] Install Samba.
[root@smb ~]# yum -y install sernet-samba sernet-samba-ad
[7] Configure Samba AD DC.
[root@smb ~]# samba-tool domain provision
# specify Realm
Realm [SERVER.WORLD]: SERVER.WORLD
# specify Domain name
Domain [SERVER]: SMB01
# Enter with default because it sets DC
Server Role (dc, member, standalone) [dc]:
# Enter with default because it uses Built-in DNS
DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]:
# confirm DNS setting and Enter if it’s OK
DNS forwarder IP address (write ‘none’ to disable forwarding) [10.0.0.1]:
# set admin password
# Do not set trivial password, if you input it, configuration wizard shows error and stops.
Administrator password:
Retype password:
Looking up IPv4 addresses
Looking up IPv6 addresses


A Kerberos configuration suitable for Samba 4 has been generated at /var/lib/samba/private/krb5.conf
Once the above files are installed, your Samba4 server will be ready to use
Server Role: active directory domain controller
Hostname: smb
NetBIOS Domain: SMB01
DNS Domain: server.world
DOMAIN SID: S-1-5-21-1554426047-3808867033-1778000025

[root@smb ~]# vi /etc/default/sernet-samba
# line 7: change
SAMBA_START_MODE=”ad”
[root@smb ~]# cp /var/lib/samba/private/krb5.conf /etc/krb5.conf
[root@smb ~]# systemctl start sernet-samba-ad
[root@smb ~]# chkconfig sernet-samba-ad on
[root@smb ~]# chkconfig sernet-samba-smbd off
[root@smb ~]# chkconfig sernet-samba-nmbd off
[root@smb ~]# chkconfig sernet-samba-winbindd off
[8] Raise the domain level to 2008 R2.
[root@smb ~]# samba-tool domain level raise –domain-level 2008_R2 –forest-level 2008_R2
Domain function level changed!
Forest function level changed!
All changes applied successfully!
# show domain level
[root@smb ~]# samba-tool domain level show
Domain and forest function level for domain ‘DC=server,DC=world’

Forest function level: (Windows) 2008 R2
Domain function level: (Windows) 2008 R2
Lowest function level of a DC: (Windows) 2008 R2

VMware Tools on CentOS 6.5 Minimal

The purpose of this guide is provide instructions for installing vmware tools for CentOS 6.5 Minimal.

Install repository keys

# rpm –import http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-DSA-KEY.pub
# rpm –import http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub
Create repository file

echo -e “[vmware-tools]\nname=VMware Tools\nbaseurl=http://packages.vmware.com/tools/esx/5.5latest/rhel6/\$basearch\nenabled=1\ngpgcheck=1” > /etc/yum.repos.d/vmware-tools.repo
Using cat, you can review the results

# cat /etc/yum.repos.d/vmware-tools.repo

[vmware-tools]
name=VMware Tools
baseurl=http://packages.vmware.com/tools/esx/5.5latest/rhel6/$basearch
enabled=1
gpgcheck=1
Install VMware Tools

# yum -y install vmware-tools-esx-nox
alternatively, if using xorg’s desktop GUI

# yum -y install vmware-tools-esx
Done!

Reboot the system to utilize the new drivers.

# reboot

removing outdated ssh fingerprints from known_hosts with sed or … ssh-keygen

Ref: http://www.screenage.de/blog/2008/05/28/removing-outdated-ssh-fingerprints-from-known_hosts-with-sed-or-ssh-keygen/

At least from the last issue in Debian-based systems including Ubuntu you might know the pain of getting the message from you ssh client that the server host key has changed as ssh stores the fingerprint of ssh daemons it connects to. Actually this is a neat feature because it helps you detecting man in the middle attacks, dns issues and other things you probably should notice.

Until recently I opened the file .ssh/known_hosts in vim, deleted the entry, saved the file and started over again. I randomly checked “man ssh” which gives you a lot of hints about the usage of known_hosts but I just did not find information about how to delete an old fingerprint or even overwrite it. I imagined something like “ssh –update-fingerpring hostname” with an interactive yes/no question you cannot skip. There is the setting “StrictHostKeyChecking” that might get you out of the fingerprint-has-changed-trouble but it does not solve the real problem as you want those checks.

So after hanging around with Mnemonikk discussing this he pointed out a very simple method with “sed” that is really handy and helps you understanding sed more deeply. You can advise “sed” to run a command on a specific line. So have a look at this session:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ ssh secrethost
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
[…]
Offending key in /home/ccm/.ssh/known_hosts:46
[…]
Host key verification failed.
$ sed -i “46 d” .ssh/known_hosts
$ ssh secrethost
The authenticity of host ‘secrethost (1.2.3.4)’ can’t be established.
RSA key fingerprint is ab:cd:ef:ab:cd:ef:ab:cd:ef:ab:cd:ef:ab:cd:ef:ab.
Are you sure you want to continue connecting (yes/no)?
We just took the line number 46 which ssh complains about and run in in-place-editing mode (-i) with the command run on line 46 the command delete (d). That was easy, wasn’t it? Small lesson learned about sed. Thank you Mnemonikk (he is currently working on a screencast about screen if you let me leak some information here :).

But to be honest I’s still looking for the “official” method the delete a key from known_hosts. Therefore I browsed through the man pages and finally found what I was looking for in “man ssh-keygen”. Yes, definitely zero points for usability as deleting with a tool named “generator” is confusing but it works, however. You can advice ssh-keygen to delete (-R) fingerprints for a hostname which helps you when you turned hashed hostnames on in you known_hosts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ ssh secrethost
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[…]
Offending key in /home/ccm/.ssh/known_hosts:63
[…]
Host key verification failed.
[ccm@hasung:255:/etc/ssh]$ ssh-keygen -R secrethost
/home/ccm/.ssh/known_hosts updated.
Original contents retained as /home/ccm/.ssh/known_hosts.old
[ccm@hasung:0:/etc/ssh]$ ssh secrethost
The authenticity of host ‘secrethost (1.2.3.4)’ can’t be established.
RSA key fingerprint is ab:cd:ef:ab:cd:ef:ab:cd:ef:ab:cd:ef:ab:cd:ef:ab.
Are you sure you want to continue connecting (yes/no)?
So “ssh-keygen -R hostname” is a nice syntax as you even do not have to provide the file name and path for known_hosts and it works with hashed names. Nevertheless I’ll also use the sed syntax – keep it trained it’ll help you in other cases also.

How to build a scalable small business lab/environment…

Let’s start off with these simple focus points.

    1. What is scalable to you?
    2. What is your budget for your criteria?
    3. Who plans to use it?
    4. How easy/convenient do you want it to be?

There are more questions you can ask yourself, but it will be more catered to customizing usually.

Let’s start with what scalable means (or should mean) to you.

1. What the heck does being scalable have to do with me?

When I have discussed scalable environments it usually means that you can either scale out quickly or handle user facing failures without much downtime.

What this should mean to you?

If you want to have an environment that you can take to a selling point you need to be able to convince most importantly yourself that the environment is stable, because stable may not always be scalable, but scalable always has to be stable.

Let’s move on to budget.

2. How does my budget affect my environment?

Usually it doesn’t for a lab especially if you are just sampling open source projects, but it usually does for larger facing projects like collaboration environments or with larger scaled teams, but let’s focus on one particular goal, can your environment be scaled out?

If you have a web server, a database server, and a user directory service; and they all are housed in the same unit/appliance, it is not scalable. You have one single point of failure, and most certainly will face downtime during your failure incident.

What you could do to resolve this is to use virtualization with templates.

What does that even mean?

It means that you use your physical server to run virtual computers that serve those services to your users, and as long as redundant storage is used, can bring up your virtual box on a new computer nearly instantly during your failure incident, this is one example of being scalable.

The price point for this becomes a fraction of cost for every virtual machine you can successfully run on your physical hardware.

Let’s move on to to your expected user-base.

3. Why should I care who uses this lab/environment?

Well for starters, if you are a low-profile user that doesn’t expect much and everything always is good enough, then this doesn’t concern you and you can easily move on to determining the complexity of your environment, because remember, only you are using it.

But what if your user base is not just you, what if it’s 100+ people. Well that’s a lot more, and a lot more people to remind you how much they hate whatever system you put them in front of. Which if you haven’t dealt with yet, is more traumatizing then the research and development of the actual product.

While this may sound daunting, it won’t be as long as you maintain your goals throughout this initiative.

The most important thing to consider during the complexity phase of planning is to recognize that the more difficult you make it for yourself, at ~02:00 you will be kicking yourself begging why couldn’t you just make it easier.

So that about raps up the convenience section.

Hopefully after reading this, you will understand some basic tricks to make an environment scalable as well as stable.

Thanks for reading.

Extend a CentOS Oracle VirtualBox Image with more Disk Space

Reposted from: http://www.munzandmore.com/2013/ora/extend-a-centos-oracle-virtualbox-image-with-more-disk-space

This is a note to myself. Hopefully good enough for me to reuse it one day. So the following instructions will probably only give you a rough idea if you found this page looking for help on Google.
Anyway, these steps worked fine for me. What a bliss not having the file systems 98% full when starting a project. Somehow, I always run out of disk space when I install SOA Suite. No matter how big I initially size it.
The challenge certainly is to get VBoxManage, fdisk and lvm right without completely messing up your system.

Warning!

fdisk and to a lesser extend lvm are razor sharp tools that can easily cause bleeding wounds. So make sure you have a backup (< - repeat this last sentence after me). On Host side (e.g. Windows 7 here) VBox instance has to be shut down for the following steps. Extend the VBox image Run the from the command line on the host system: C:\Users\frank>“\Program Files\Oracle\VirtualBox\VBoxManage.exe” modifyhd –resize 29696 “\01_work\30 vms\virt
box\CentOS 6.4 64b STUDENT\CentOS 6.4 64b STUDENT.vdi”
On Guest side (e.g. CentOS 6.4 here)

Stay calm
Double check that you are on the guest side. Runing fdisk accidentially on the host side can destroy your whole computer, whereas running it on the guest side typically reduces the risk to destroy your virtual image only.
fdisk
Use fdisk -l to list devices, then e.g. fdisk /dev/sda to add another primary partition (coomand n), next free number (e.g. 3), of type 8e (Linux LVM) (t), print part table (p), write table (w). Reboot…

Add new partition as physical volume (PV)
[root@ccloud12 ~]# lvm
lvm> pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created

Extend existing volume group (VG)
lvm> vgextend vg_ccloud12 /dev/sda3
Volume group “vg_ccloud12” successfully extended

Find out partition name
lvm> lvdisplay
— Logical volume —
LV Path /dev/vg_ccloud12/lv_root

Extend logical volume
lvm> lvextend -L+8.48G /dev/vg_ccloud12/lv_root
Rounding size to boundary between physical extents: 8.48 GiB
Extending logical volume lv_root to 25.56 GiB
Logical volume lv_root successfully resized
Resize the File System (Guest System)
resize2fs -F /dev/vg_ccloud12/lv_root
That’s it
Try df -h and enjoy your new diskpace.

Let me know if you had any success eg. using Oracle Enterprise Linux. Any super secret tips how to improve or shorten this are welcome.

Remove all packages marked as rc by dpkg

re-posted from: http://linuxprograms.wordpress.com/2010/05/12/remove-packages-marked-rc/

Let’s see all the packages marked as rc by dpkg. Know more about the state rc. This state means that the configuration files are not yet removed. You can see how a single package can be removed.

$ dpkg –list |grep “^rc”
rc bsh 2.0b4-10ubuntu2 Java scripting environment (BeanShell) Versi
rc devicekit-disks 007-2ubuntu6 abstraction for enumerating block devices
rc devicekit-power 011-1ubuntu2 abstraction for power management
rc dvipdfmx 1:20090115-1.2 A DVI to PDF translator with CJK support
rc gnome-blackjack 1:2.28.0-0ubuntu3 Blackjack casino card game
rc groovy 1.6.4-4ubuntu2 Agile dynamic language for the Java Virtual
rc kdepim-runtime-data 4:4.3.2-0ubuntu1 shared data files for the KDE 4 base runtime
Let’s extract out the packages marked as rc

$ dpkg –list |grep “^rc” | cut -d ” ” -f 3
bsh
devicekit-disks
devicekit-power
dvipdfmx
gnome-blackjack
groovy
kdepim-runtime-data
Now let’s remove all the packages marked as rc.

$ dpkg –list |grep “^rc” | cut -d ” ” -f 3 | xargs sudo dpkg –purge

[sudo] password for abcde:
(Reading database … 239389 files and directories currently installed.)
Removing bsh …
Purging configuration files for bsh …
Removing devicekit-disks …
Purging configuration files for devicekit-disks …
Removing devicekit-power …
Purging configuration files for devicekit-power …
dpkg: warning: while removing devicekit-power, directory ‘/var/lib/DeviceKit-power’ not empty so not removed.
Removing dvipdfmx …
Purging configuration files for dvipdfmx …
Removing gnome-blackjack …
Purging configuration files for gnome-blackjack …
Removing groovy …
Purging configuration files for groovy …
Removing kdepim-runtime-data …
Purging configuration files for kdepim-runtime-data …
Removing kdepim-runtime-libs4 …
See how we have used xargs and the command dpkg –purge in combination.

The Easiest Mail Server Is Also The Best

Re-posted from: www.daijoubu.ws/the-easiest-mail-server-is-also-the-best/

During my struggle trying to set up the best, most reliable, mail server possible, I tried several configurations, both ready-to-use, like iRedMail, as well as very customized setups, which included the likes of Postfix + Courier + PostgreSQL authentication/vmail + Horde Groupware + spamfilters/anti-viruses/greylistings.

It’s not an easy task, but two tools makes it extremely straightforward: Yaffas + Zarafa.
And I’m really baffled on why it’s not widely adopted/documented.

Yaffas is a server administration framework, focused on groupware/mail, but not restricted to that. It sports a great ajab web interface for administering common server tasks, like managing users, installing ssl certs, whitelisting hostnames, etc. You can even start/stop/restart services, shutdown and reboot your server, and download log files. It’s also totally FOSS.

The main feature is Zarafa, an awesome and complete groupware client, including mail, calendar, tasks and notes. Its WebApp UI is beautiful, easy and intuitive. You can demo it here: https://demo.zarafa.com/webapp

Zarafa uses its own IMAP/POP3 server, or MDA (mail delivery agent), and also a CalDAV/iCal server (calendar and tasks), but no CarDAV server (contacts) or any way to sync its notes. We have a way to address the lack of contacts sync, which we explain later.

Yaffas + Zarafa Mail Server How-To
This tutorial will be using Ubuntu 12.04 Server as our operating system. There are also repositories for Debian and RHEL, and you can always install it from source. Adapting it to your system should be just a few minimal changes.

This tutorial assumes that your OS is brand new and clean, installed specific for this purpose. Yaffas installation makes changes and overrides several configuration files. If you install it in a production environment it will break your stuff!
Preparing your server
It’s recommended to use at least 512MB of memory, which still is a bit low. SpamAssassin, Amavids-new and ClamAV will probably not start using this setting. We will address this and provide more stability adding some SWAP memory:

To make sure you don’t already have a SWAP partition, check your current SWAP status:

swapon -s

If none filename, type or size appears, you don’t have one, so:

dd if=/dev/zero of=/swap bs=1024 count=2097152

mkswap /swap

chown root:root /swap

chmod 0600 /swap

swapon /swap

echo /swap swap swap defaults 0 0 >> /etc/fstab

This will add 2GB of SWAP. Again, check the current SWAP status with:

swapon -s

Let’s also set your FQDN as your hostname:

hostname cloudmail.com

This will change the /etc/hostname file and sets your hostname on-the-fly, without the need to reebot your server. Ubuntu stores hostnames in /etc/hosts too, so it’s safe to add yours there, before any other hostnames listed (eg. localhost).

Adding repo and installing
echo “deb http://repo.yaffas.org/releases/latest/precise ./” >> /etc/apt/sources.list

wget -O – http://repo.yaffas.org/repo.deb.key | apt-key add –

apt-get update

apt-get install yaffas

This automatically installs Postfix (SMTP server, aka MTA, aka the one which send emails), MySQL (database used by several applications to store data), OpenLDAP (user management), a complete set of security tools (SpamAssassin, Amavids-new, ClamAV and Policyd-weight), Apache (webserver, mainly used by Zarafa, since Yaffas uses its own Perl webserver), Fetchmail (optional mail retriever, starts disabled), and the whole Zarafa suite.

Initial components onfiguration
Upon installation, Yaffas will prompt you with some configuration screens, starting with Kerberos:

 

 

Leave them all untouched, except the hostname section, where you need to enter the hostname you set earlier.

You’ll them be prompted with MySQL and LDAP password. These are very important and sensitive stepts. Create strong passwords and store them in a safe place for later. LDAP will also ask you some more questions, leave them unchanged, with default values. Last one is Postfix, choose “Local only” and enter your hostname as your FQDN.

Initial Yaffas configuration
Yaffas’ server run on port 10000. To access it, point your browser to:

 

 

https://cloudmail.com:10000
It comes with a basic self-signed SSL cert and your browser will complain about this. Allow exception and connect anyways. Username is admin and password is yaffas. Following are the 5 steps needed to configure Yaffas:

1/5 Yaffas’ Wizard/Quick Setup will run on this initial configuration;

2/5 First proper step is to change your admin password;

3/5 Configure MySQL connection with credentials you created earlier;

4/5 Mail server settings, using your FQDN/hostname on Primary domain name. Other 3 inputs are only need if using smarthost;

5/5 This last step is critical. This will create your first user and enable local authentication. Only fill these inputs if your language is ENGLISH, otherwise leave them blank. Why? One might ask. Simple: By setting this now, Yaffas will also create Zarafa’s folders used by mails, calendars, tasks and contacts, influencing later steps, and you won’t be able to change them afterwards.

Using Yaffas
I won’t explain in every detail how to use Yaffas, just the common tasks and steps necessary to get your mail server up and running.

the-easiest-mail-server-is-also-the-best-6the-easiest-mail-server-is-also-the-best-7the-easiest-mail-server-is-also-the-best-8
anteriorpróximo
Now login to Yaffas using the “admin” username and your password. First thing you need to do is set your language. On the top-right section, in “Languages” menu.

When login to Yaffas, you’ll always land on “Information” page, a dashboard containing all the information you need to monitor your server, like memory usage, average load and file system stats. Behind that submenu is “Services”, a list of all the services pertinent to your mail server, you can start, stop, restart and remove services from boot easily. Also in this page you have system clock, clock sync server and power off/reboot tabs.

On that same menu, at the first item, you can configure SSL certs for your mail server. That’s a very nice tool which handles creation and signing of keys and certs. You’ll probably want a commercial cert, signed by a trusted authority. Yaffas got you covered here, you can easily upload your certs and everything will be automatically configured.

Create and Upload SSL certs
Create your certificate’s CSR and KEY files with:

openssl req -out cloudmail.com.csr -new -newkey rsa:2048 -nodes -keyout cloudmail.com.key

The certificate provider you choose will ask for the contents of CSR file generated above in order to create your certificate. Provide it and they will send you another file, a CRT file containing the proper certificate. Upload it to your server. Yaffas needs the contents of KEY and CRT combined into a single PEM file. You can do this with:

cat cloudmail.com.key yourcert.crt > cloudmail.com.pem

Now download this file back to your computer, go to Yaffas administration System > Certificate / Key Management > Upload Certificate, and upload your certificate.

Configuring Zarafa
Now go to Zarafa menu, Configuration submenu. Activate POP and IMAP, you can also configure the max size of attachments, default mail quota and days to keep mails in trash.

That’s all you’ll need to do for basic Zarafa configuration. Everything’s already set up.

Authentication method and user creation
Go to “Accounts” menu, “Authentication” server, and select the Local Authentication method, which is the local OpenLDAP server you have configured before.

In “User Management” you can create, edit and delete users. Go to “Add User” and enter your user’s username, First Name, Surname, email, password and of this user is a Zarafa admin. You can define individual mailbox quota or use the default quota you defined earlier.

Using Zarafa’s WebApp
Access Zarafa’s client (WebApp):

 

 

https://cloudmail.com/webapp

You can only login with your username (not the email) and password. Zarafa will ask you some basic information the first time you access it, the most important one being your language, which will define your whole interface locale. Configure it according to your needs.

Zarafa features a beautiful and easy to use AJAX interface, with email, calendar, contacts, tasks and notes.

Thunderbird integration
First we need to open Postfix’s secure ports 465 and 587:

nano /etc/postfix/master.cf

Remove # from submission … line, exit saving the file.

Create a new account in Thunderbird and it will probably detect all ports and set automatic configuration but it could complain about your username. This happens because Zarafa Gateway will also only login with your LDAP username and its not always the same as the prefix of your email.

For example, you have a user named johndoe with john@cloudmail.com as his email, in this case Thunderbird will assume that the username is john.

If this happens just fix your username and you are good to go.

Calendar and Tasks sync
Install Lightning add-on, which will handle Calendars and Tasks for Thunderbird: https://addons.mozilla.org/pt-br/thunderbird/addon/lightning/

To sync your calendar, create a new calendar in Thunderbird’s Calendar tab, selecting WebDAV method and using this location (and username/password):

http://cloudmail.com:8080/caldav
To sync your tasks, create another calendar, with this location (and username/password):

http://cloudmail.com:8080/caldav/username/tasks
The last piece of this link will depende of your language. If it is brazilian portuguese, it will be tarefas instead of tasks.

Contacts sync
Unfortunately, Zarafa does not come with a ready-to-use CardDAV, but thanks to ZeGuiGui (original author) and Bokxing IT (current developer) there is an add-on using SabreDAV addressing this. The current development is being made in GitHub. We need git to clone it from source:

apt-get install git

Now go to /var/www and clone the repo:

git clone https://github.com/bokxing-it/sabre-zarafa.git

Change the ownership of sabre-zarafa/data and sabre-zarafa/debug.txt to the webserver’s user:

chown www-data:www-data /var/www/sabre-zarafa/data

chmod 0750 /var/www/sabre-zarafa/data

chown www-data:www-data /var/www/sabre-zarafa/debug.txt

chmod 0640 /var/www/sabre-zarafa/debug.txt

Create Sabre-Zarafa Apache’s configuration file:

nano /etc/apache2/sites-available/sabre-zarafa

And put the content if this Gist inside it:

Now enable Apache’s mod_rewrite:

a2enmod rewrite

Enable the Sabre-Zarafa file:

a2ensite sabre-zarafa

Restart Apache:

service apache2 restart

Thunderbird also does not have any CardDAV support by default, but you can accomplish that with SOGo Connection add-on: http://www.sogo.nu/files/downloads/extensions/sogo-connector-17.0.4.xpi

Now open Thunderbird’s Address Catalog, go to “File”, “New”, “Remote Address Book”, enter a name for this Catalog, and this location:

http://cloudmail.com/sabre-zarafa/addressbooks/username/Contacts/
Like tasks sync, the last piece of this URL depends on your languages. Contacts if you speak english and Contatos, if you speak brazilian portuguese, for example.

That’s it. Now you have a complete mail server, with desktop mail clients and mobile exchange integration.

how do I disable suspend when my laptop is plugged in and closed?

[I want my laptop to only go into suspend mode when it’s un-plugged, not when it is plugged in and the lid is closed. How can I disable that?]

Since fedora choosu to use gnome 3.x, the dconf-editor doesn’t work. This is because systemd override Gnome’s ACPI Settings. A non-elegant solution is to edit /etc/systemd/logind.conf:

su -c ‘vi /etc/systemd/logind.conf’
and set HandleLidSwitch to ignore:

HandleLidSwitch=ignore
and then restart systemd

su -c ‘systemctl restart systemd-logind.service’
Hope that help

How To Protect SSH with fail2ban on Ubuntu 12.04

About Fail2Ban
Servers do not exist in isolation, and those virtual private servers with only the most basic SSH configuration can be vulnerable to brute force attacks. fail2ban provides a way to automatically protect virtual servers from malicious behavior. The program works by scanning through log files and reacting to offending actions such as repeated failed login attempts.

Step One—Install Fail2Ban
Use apt-get to install Fail2Ban

sudo apt-get install fail2ban
Step Two—Copy the Configuration File
The default fail2ban configuration file is location at /etc/fail2ban/jail.conf. The configuration work should not be done in that file, however, and we should instead make a local copy of it.

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
After the file is copied, you can make all of your changes within the new jail.local file. Many of possible services that may need protection are in the file already. Each is located in its own section, configured and turned off.

Step Three—Configure the Defaults in Jail.Local
Open up the the new fail2ban configuration file:

sudo nano /etc/fail2ban/jail.local
The first section of defaults covers the basic rules that fail2ban will follow. If you want to set up more nuanced protection on your virtual server, you can customize the details in each section.

You can see the default section below.

[DEFAULT]

# “ignoreip” can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8
bantime = 600
maxretry = 3

# “backend” specifies the backend used to get files modification. Available
# options are “gamin”, “polling” and “auto”.
# yoh: For some reason Debian shipped python-gamin didn’t work as expected
# This issue left ToDo, so polling is default backend for now
backend = auto

#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost
Write your personal IP address into the ignoreip line. You can separate each address with a space. IgnoreIP allows you white list certain IP addresses and make sure that they are not locked out. Including your address will guarantee that you do not accidentally ban yourself from your own server.

The next step is to decide on a bantime, the number of seconds that a host would be blocked from the VPS if they are found to be in violation of any of the rules. This is especially useful in the case of bots, that once banned, will simply move on to the next target. The default is set for 10 minutes—you may raise this to an hour (or higher) if you like.

Maxretry is the amount of incorrect login attempts that a host may have before they get banned for the length of the ban time.

You can leave the backend as auto.

Destemail is the email that alerts get sent to. If you have a mail server set up on your droplet, Fail2Ban can email you when it bans an IP address.

Additional Details—Actions
The Actions section is located below the defaults. The beginning looks like this:

#
# ACTIONS
#

# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define
# action_* variables. Can be overridden globally or per
# section within jail.local file
banaction = iptables-multiport

# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional ‘mail’.
mta = sendmail

# Default protocol
protocol = tcp
[…]
Banaction describes the steps that fail2ban will take to ban a matching IP address. This is a shorter version of the file extension where the config if is located. The default ban action, “iptables-multiport”, can be found at /etc/fail2ban/action.d/iptables-multiport.conf

MTA refers to email program that fail2ban will use to send emails to call attention to a malicious IP.

You can change the protocol from TCP to UDP in this line as well, depending on which one you want fail2ban to monitor.

Step Four (Optional)—Configure the ssh-iptables Section in Jail.Local
The SSH details section is just a little further down in the config, and it is already set up and turned on. Although you should not be required to make to make any changes within this section, you can find the details about each line below.

[ssh]

enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6
Enabled simply refers to the fact that SSH protection is on. You can turn it off with the word “false”.

The port designates the port that fail2ban monitors. If you have set up your virtual private server on a non-standard port, change the port to match the one you are using:

eg. port=30000
The filter, set by default to sshd, refers to the config file containing the rules that fail2ban uses to find matches. sshd refers to the /etc/fail2ban/filter.d/sshd.conf.

log path refers to the log location that fail2ban will track.

The max retry line within the SSH section has the same definition as the default option. However, if you have enabled multiple services and want to have specific values for each one, you can set the new max retry amount for SSH here.

Step Five—Restart Fail2Ban
After making any changes to the fail2ban config, always be sure to restart Fail2Ban:

sudo service fail2ban restart
You can see the rules that fail2ban puts in effect within the IP table:

sudo iptables -L

Defragmenting, shrinking, and cleaning up VMware Fusion virtual machine disks

Details
You may be able to reduce the size of a VMware Fusion virtual machine’s sparse disk if it does not have any snapshots. This article provides information on defragmenting the virtual hard drive from within Windows, shrinking the virtual disk from within Windows and Linux, and cleaning up (defragmenting) the virtual disk in Mac OS.

Note: It is not possible to reduce the size of a Fusion virtual machine’s pre-allocated disk. The size of a pre-allocated disk is always approximately equal to the size allocated to the virtual machine’s operating system.

A sparse disk is equal in size to the space the guest operating system has used. This size is not necessarily the same as the space that the guest operating system is currently using. This is because, when you tell an operating system to delete a file, it does not actually delete the file — instead, it stops remembering what is stored in the space that was is used by the file. This is similar to having an unlabeled VCR tape or rewritable CD/DVD.If there is no label, the presumption is that you are free to record on it. So, when a file is deleted, the guest operating system stops marking that space as used. However, the data hasn’t actually been removed from the disk and so Fusion still counts it. Defragmenting and then shrinking the disk is necessary to free up this space that’s no longer being used.

Solution
Fusion virtual machines can be pre-allocated or sparse. In a pre-allocated virtual machine, the size of the virtual disk file (or files, if you have chosen to split the virtual machine into 2 GB files) is equal to the size of the virtual machine. In a sparse virtual machine, the size of the virtual disk file (or files) is equal to the total used space of the virtual machine.

Your virtual machine bundle is always larger than the size of your virtual disks because the bundle contains snapshots, suspend state files (if the virtual machine is suspended), settings files, and logs. For more information, see Contents of the virtual machine bundle in Fusion (1021016).

However, if the size of your virtual disks is significantly larger than the used space shown in the virtual machine’s Operating System, it is possible to reduce this size.

To reduce the size of the disk, you must defragment the disk within Windows, shrink the virtual disk using VMware Tools, and then clean up the virtual disk from within Mac OS using the built-in Fusion utility.

Notes:

This process does not apply to pre-allocated disks. To make a pre-allocated disk sparse, see Making a Fusion virtual disk pre-allocated or sparse (1021565).

To determine if your disk is sparse or pre-allocated, check the virtual disk settings:

Launch Fusion.
From the menu bar, go to Virtual Machine > Settings.
Click Hard Disk section.
Under Advanced, look for the Pre-allocated check box.

If Pre-allocated is selected, then your virtual disk is pre-allocated. If Pre-allocated is not selected, your virtual disk is sparse.

If your disk has snapshots, you need to delete the snapshots before trying to reduce the size of the disk. For more information, see Deleting snapshots in VMware Fusion (1020245).
Defragmenting within Windows

In a Windows virtual machine, you must first run a disk defragment from within Windows. Defragmenting within Windows ensures that all of the used spaces are contiguous. You can then reduce the size of the virtual disk.

To run a disk defragment within Windows, follow the instructions from Microsoft:

Windows XP: How to Defragment Your Disk Drive Volumes in Windows XP
Windows Vista: Improve performance by defragmenting your hard disk
Windows 7: Improve performance by defragmenting your hard disk
Note: The preceding links were correct as of September 9, 2013. If you find that a link is broken, provide feedback and a VMware employee will update the link.

Shrinking the virtual disk

After defragmenting the virtual disk, use VMware Tools to erase empty disk sectors at the end of the disk, so that and the space is freed up.

Note: In Fusion 6.x and 5.x, shrinking is automatically done while Cleaning up the disk. Therefore, this option is removed from VMware Tools Panel.

To shrink the virtual disk in VMware Fusion 4.x and earlier:

Open the VMware Tools Control Panel / Toolbox:

In Windows: Double click the VMware Tools icon in the system tray, or go to Start > Control Panel > VMware Tools.
In Linux:

Open a command prompt. For more information, see Opening a command or shell prompt (1003892).
Run this command:

vmware-toolbox

Click the Shrink tab.
Ensure that your boot drive is selected.
Click Prepare to Shrink and then follow the prompts.

Caution: Do not shutdown your virtual machine or the Mac while the disk is shrinking. Do not try to cancel the process. Interrupting this process can cause irreparable damage to your virtual disk and you may not be able to start your virtual machine again.
Cleaning up the disk

After shrinking your virtual disk, Fusion ensures that the virtual disk is optimized for Mac OS X. Mac OS X does this automatically for smaller files. However, virtual machine files are too large and you must manually clean up the disk.

To clean up your virtual disk:

In Fusion 6.x, 5.x and 4.x:

Shut down your virtual machine.
Go to Virtual Machine > Settings > General.
Select Clean Up Virtual Machine.
In Fusion 3.x and earlier:
Shut down your virtual machine.
Go to Virtual Machine > Settings > Hard Disks.
Select Clean Up Disk.