<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>controlc.de &#187; exchange</title>
	<atom:link href="http://controlc.de/tag/exchange/feed/" rel="self" type="application/rss+xml" />
	<link>http://controlc.de</link>
	<description>mehr als nur ein Notizblock</description>
	<lastBuildDate>Mon, 16 Apr 2012 12:43:35 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>debian &#124; Zertifikate für Exchange erstellen und einbinden</title>
		<link>http://controlc.de/2009/07/22/debian-zertifikate-fur-exchange-erstellen-und-einbinden/</link>
		<comments>http://controlc.de/2009/07/22/debian-zertifikate-fur-exchange-erstellen-und-einbinden/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 13:50:07 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[zertifikate]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=768</guid>
		<description><![CDATA[Gestern musste ich feststellen, das mein Exchange keine Mails mehr an mein Mail-Gateway verschickt. Nach einer Weile habe ich dann bemerkt, das das Zertifikat abgelaufen ist. Da sich inzwischen durch den Schwenk auf einen anderen vServer auch die CA geändert hat, wollte ich in dem Zuge gleich alles gerade rücken. Mit meinem schon bekannten Zertifikate-Skript [...]]]></description>
			<content:encoded><![CDATA[	<p>Gestern musste ich feststellen, das mein Exchange keine Mails mehr an mein Mail-Gateway verschickt. Nach einer Weile habe ich dann bemerkt, das das Zertifikat abgelaufen ist. Da sich inzwischen durch den Schwenk auf einen anderen vServer auch die CA geändert hat, wollte ich in dem Zuge gleich alles gerade rücken.</p>
	<p>Mit meinem schon <a href="http://controlc.de/2009/05/11/zertifikaterstellungsskript/">bekannten Zertifikate-Skript</a> habe ich problemlos ein neues Zertifikat für den Exchange ausgestellt</p>
	<p>Jetzt aber muss das Zertifikat in ein für den Exchange lesbares Format gewandelt werden. Dazu exportieren wir den privaten wie auch den öffentlichen Teil des Zertifikats als PK12</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl pkcs12 <span style="color: #660033;">-export</span> <span style="color: #660033;">-in</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>cert.pem <span style="color: #660033;">-inkey</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>key.pem <span style="color: #660033;">-out</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>windows.p12</pre></div></div>

	<p>Und natürlich muss auch das neue Zertifikat der Root-CA mit. Dazu reicht es aber das schon erstellte PEM-File zu kopieren.</p>
	<p><span id="more-768"></span>Nachdem wir beide Dateien auf den Exchange kopiert habe müssen diese als Zertifikate importiert werden. Dazu öffnen wir die <em>Microsoft Management Console (MMC)</em> und laden das Snap-In <em>Zertifikate</em></p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/mmc-snapin-zertifikate.png" class="floatbox" rev="group:768 caption:`MMC Snap-In Zertifikate`"><img class="aligncenter size-medium wp-image-769" title="MMC Snap-In Zertifikate" src="http://controlc.de/wp-content/uploads/2009/07/mmc-snapin-zertifikate-300x156.png" alt="MMC Snap-In Zertifikate" width="300" height="156" /></a></p>
	<p>Bei den weiteren Abfragen bitte wie auf den Screenshots zu sehen ist vorgehen.</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Computerkonto1.png" class="floatbox" rev="group:768 caption:`MMC Snap-In Zertifikate Computerkonto`"><img class="aligncenter size-medium wp-image-773" title="MMC Snap-In Zertifikate Computerkonto" src="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Computerkonto1-300x216.png" alt="MMC Snap-In Zertifikate Computerkonto" width="300" height="216" /></a></p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Computerkonto1.png" class="floatbox" rev="group:768"></a><a href="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-lokaler-Computer.png" class="floatbox" rev="group:768 caption:`MMC Snap-In Zertifikate lokaler Computer`"><img class="aligncenter size-medium wp-image-781" title="MMC Snap-In Zertifikate lokaler Computer" src="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-lokaler-Computer-300x215.png" alt="MMC Snap-In Zertifikate lokaler Computer" width="300" height="215" /></a></p>
	<p>Zuerst werden die beiden Zertifikate als eigene Zertifikate importiert.</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Eigene-Zertifikate-2.png" class="floatbox" rev="group:768 caption:`MMC Snap-In Zertifikate - Eigene Zertifikate`"><img class="aligncenter size-full wp-image-788" title="MMC Snap-In Zertifikate - Eigene Zertifikate" src="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Eigene-Zertifikate-2.png" alt="MMC Snap-In Zertifikate - Eigene Zertifikate" width="186" height="67" /></a></p>
	<p>Dazu auf der rechten Seite mit einem Rechtsklick und dann <em>Alle Aufgaben/Importieren…</em> beide Zertifikate einladen.</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Import.png" class="floatbox" rev="group:768 caption:`MMC Snap-In Zertifikate - Import`"><img class="aligncenter size-medium wp-image-775" title="MMC Snap-In Zertifikate - Import" src="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-Import-300x148.png" alt="MMC Snap-In Zertifikate - Import" width="300" height="148" /></a></p>
	<p>Dann muss das Zertifikat der Root-CA noch in die <em>Vertrauenswürdigen Stammzertifizierungsstellen</em> verschoben werden.</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-RootCAs-2.png" class="floatbox" rev="group:768 caption:`MMC Snap-In Zertifikate - RootCAs`"><img class="aligncenter size-full wp-image-789" title="MMC Snap-In Zertifikate - RootCAs" src="http://controlc.de/wp-content/uploads/2009/07/MMC-Snap-In-Zertifikate-RootCAs-2.png" alt="MMC Snap-In Zertifikate - RootCAs" width="288" height="81" /></a></p>
	<p>Damit hat man den Grundstock geschaffen. Anschließend kann dann das Zertifikat an den entsprechenden Stellen in den Exchange eingebunden werden.</p>
	<p>Zuerst für SMTPs im Exchange System-Manager</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/Exchange-SMTPs-1.png" class="floatbox" rev="group:768 caption:`Exchange - SMTPs 1`"><img class="aligncenter size-medium wp-image-784" title="Exchange - SMTPs 1" src="http://controlc.de/wp-content/uploads/2009/07/Exchange-SMTPs-1-300x210.png" alt="Exchange - SMTPs 1" width="300" height="210" /></a></p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/07/Exchange-SMTPs2.png" class="floatbox" rev="group:768 caption:`Exchange - SMTPs 2`"><img class="aligncenter size-medium wp-image-778" title="Exchange - SMTPs 2" src="http://controlc.de/wp-content/uploads/2009/07/Exchange-SMTPs2-269x300.png" alt="Exchange - SMTPs 2" width="269" height="300" /></a></p>
	<p>Analog dazu trägt man das neue Zertifikat auch in IMAPs ein.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/07/22/debian-zertifikate-fur-exchange-erstellen-und-einbinden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>postfix &#124; eigener Einlieferungsweg für Exchange-Server definieren</title>
		<link>http://controlc.de/2009/06/26/postfix-eigener-einlieferungsweg-fur-exchange-server-definieren/</link>
		<comments>http://controlc.de/2009/06/26/postfix-eigener-einlieferungsweg-fur-exchange-server-definieren/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 21:15:02 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=732</guid>
		<description><![CDATA[Das Problem in einer Installation wie der meinen ist, das für das Mail-Gateway jeder einliefernde Server gleich aussieht und somit auch gleich behandelt wird. Da ich aber für meinen eigenen Exchange-Server nahezu die Hand ins Feuer legen kann, möchte ich natürlich, das die ressourcenfressenden Tests auf alle Mails, die der Exchange an das Mail-Gateway übergibt, [...]]]></description>
			<content:encoded><![CDATA[	<p>Das Problem in einer Installation wie der meinen ist, das für das Mail-Gateway jeder einliefernde Server gleich aussieht und somit auch gleich behandelt wird. Da ich aber für meinen eigenen Exchange-Server nahezu die Hand ins Feuer legen kann, möchte ich natürlich, das die ressourcenfressenden Tests auf alle Mails, die der Exchange an das Mail-Gateway übergibt, nicht angewendet werden. Ich habe mich dabei für folgende Lösung entschieden:<span id="more-732"></span></p>
	<p>Zuerst habe ich einen neuen Service in <code>/etc/services</code> definiert</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Local services</span>
exchange        <span style="color: #000000;">12345</span><span style="color: #000000; font-weight: bold;">/</span>tcp                       <span style="color: #666666; font-style: italic;"># Hilfsport für Exchangeeinlieferung</span></pre></div></div>

	<p>Anschließend wird ein neuer Transportweg in <code>/etc/postfix/master.cf</code> definiert</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">exchange inet n    -       n       -       -     smtpd
        <span style="color: #660033;">-o</span> <span style="color: #007800;">content_filter</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_delay_reject</span>=no
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_helo_restrictions</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_sender_restrictions</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_recipient_restrictions</span>=permit_tls_clientcerts,reject
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_data_restrictions</span>=reject_unauth_pipelining
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_end_of_data_restrictions</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_restriction_classes</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">mynetworks</span>=127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_error_sleep_time</span>=<span style="color: #000000;">0</span>
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_soft_error_limit</span>=<span style="color: #000000;">1001</span>
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_hard_error_limit</span>=<span style="color: #000000;">1000</span>
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_connection_count_limit</span>=<span style="color: #000000;">0</span>
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_connection_rate_limit</span>=<span style="color: #000000;">0</span>
        <span style="color: #660033;">-o</span> <span style="color: #007800;">receive_override_options</span>=no_header_body_checks,no_unknown_recipient_checks,no_milters
        <span style="color: #660033;">-o</span> <span style="color: #007800;">local_header_rewrite_clients</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_milters</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">local_recipient_maps</span>=
        <span style="color: #660033;">-o</span> <span style="color: #007800;">transport_maps</span>=<span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>transport
        <span style="color: #660033;">-o</span> <span style="color: #007800;">relay_recipient_maps</span>=</pre></div></div>

	<p>Damit haben wir den Weg für den Exchange-Server auf dem Mail-Gateway geebnet. Nun müssen wir noch den Exchange-Server konfigurieren. Zuerst müssen wir den Smarthost  definieren, also den Server, an den der Exchange alle Mails schicken soll, für die er selber nicht zuständig ist. Das ist in unserem Fall das Mail-Gateway. Definiert wird das Ganze im Default-SMTP-Connector, in meinem Fall heißt dieser Smallbusiness-SMTP-Connector und ist zu unter <em>Administrative Gruppen/Erste administrative Gruppe/Routinggruppen/Erste Routinggruppe/Connectors</em>. Auf der Reiterkarte <em>Allgemein</em> gibt man entweder den FQDN an oder aber, wie in meinem Falle,  die IP in eckigen Klammern an.</p>
	<p><div id="attachment_735" class="wp-caption aligncenter" style="width: 310px"><a href="http://controlc.de/wp-content/uploads/2009/06/SMTP-Connector-smarthost.JPG" class="floatbox" rev="group:732 caption:`Smarthost im SMTP-Connector`"><img class="size-medium wp-image-735" title="Smarthost im SMTP-Connector" src="http://controlc.de/wp-content/uploads/2009/06/SMTP-Connector-smarthost-300x188.jpg" alt="Im SMTP-Connector wird der Smarthost definiert" width="300" height="188" /></a><p class="wp-caption-text">Im SMTP-Connector wird der Smarthost definiert</p></div></p>
	<p>Weitere Informationen findet man in der <a href="http://support.microsoft.com/?scid=kb%3Ben-us%3B314961&amp;x=17&amp;y=12">Microsoft Knowledgebase</a>.</p>
	<p>Anschließend muß man noch festlegen, an welchen Port der Exchange-Server für seine ausgehende SMTP-Kommunikation benutzt. Dies definiert man in <em>Administrative Gruppen/Erste administrative Gruppe/Server/SERVERNAME/Protokolle/SMTP</em>. Hier legt der Server nach der Grundinstallation den <em>Virtueller Standardserver für SMTP</em> an. In der Reiterkarte Übermittlung gibt es <em>Ausgeh. Verbindungen</em> und dort findet man den <em>TCP-Anschluß</em>.</p>
	<p><div id="attachment_736" class="wp-caption aligncenter" style="width: 310px"><a href="http://controlc.de/wp-content/uploads/2009/06/SMTP-outgoing-port.JPG" class="floatbox" rev="group:732 caption:`SMTP-outgoing-port`"><img class="size-medium wp-image-736" title="SMTP-outgoing-port" src="http://controlc.de/wp-content/uploads/2009/06/SMTP-outgoing-port-300x186.jpg" alt="Im virtuellen Standardserver für SMTP wird der ausgehende Port definiert" width="300" height="186" /></a><p class="wp-caption-text">Im virtuellen Standardserver für SMTP wird der ausgehende Port definiert</p></div></p>
	<p>Weitere Infos zum ausgehenden Port findet man in der <a href="http://support.microsoft.com/?scid=kb%3Ben-us%3B274842&amp;x=11&amp;y=10">Microsoft Knowledgebase</a>.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/06/26/postfix-eigener-einlieferungsweg-fur-exchange-server-definieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>debian &#124; postfix und relay_recipient_maps vom Exchange (II)</title>
		<link>http://controlc.de/2009/05/25/debian-postfix-und-relay_recipient_maps-vom-exchange-ii/</link>
		<comments>http://controlc.de/2009/05/25/debian-postfix-und-relay_recipient_maps-vom-exchange-ii/#comments</comments>
		<pubDate>Mon, 25 May 2009 10:00:58 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[spamschutz]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=474</guid>
		<description><![CDATA[Weiter gehts im schnellen Lauf, denn der Teddy gibt nicht auf Hier der versprochene zweite Teil zum Thema postfix und relay_recipient_maps vom Exchange. Nachdem wir nun nahezu automatisch die Liste aller gültigen Empfänger auf das Mail-Gateway kopieren können, müssen wir nun die Liste so aufbereiten, das postfix damit etwas anfangen kann. Bisher sieht die Liste [...]]]></description>
			<content:encoded><![CDATA[	<p><em>Weiter gehts im schnellen Lauf, denn der Teddy gibt nicht auf <img src='http://controlc.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
</em></p>
	<p><em>Hier der versprochene zweite Teil zum Thema <a href="http://controlc.de/2009/05/24/debian-postfix-und-relay_recipient_maps-vom-exchange-i/">postfix und relay_recipient_maps vom Exchange</a>.</em></p>
	<p>Nachdem wir nun nahezu automatisch die Liste aller gültigen Empfänger auf das Mail-Gateway kopieren können, müssen wir nun die Liste so aufbereiten, das postfix damit etwas anfangen kann.</p>
	<p>Bisher sieht die Liste in etwa so aus:</p>
	<blockquote><p>dn: CN=Administrator,CN=Users,DC=example,DC=de<br />
changetype: add<br />
proxyAddresses: SMTP:Administrator@example.de<br />
proxyAddresses: X400:c=DE;a= ;p=EXAMPLE;o=Exchange;s=Administrator;</p></blockquote>
	<p><span id="more-474"></span><br />
So kann man die Liste natürlich nicht an postfix geben. Wenn man sich dann die Liste genau anschaut, dann findet man viele Einträge von EMail-Adressen, die der Exchange selber benötigt und die man nicht über das Mail-Gateway erreichbar machen muß. Es müssen also folgende Dinge gemacht werden:</p>
	<ol>
	<li>Löschen der unnötigen Zeilen.</li>
	<li>Aufbereiten der Textdatei</li>
	<li>Hinzufügen des Kommandos OK zu jeder Zeile</li>
	<li>Löschen der unbenötigten Emailadressen</li>
	</ol>
	<p>Dazu verwenden wir das Script von <a href="http://www.postfix-buch.com/download/extract_e3k_recipients.tar.gz">postfix-buch.com</a>. Leider hat sich in dem Script ein kleiner Fehler eingeschlichen <img src='http://controlc.de/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> . Das Original-Script sieht so aus:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Extract all Adresses that start with SMTP or smtp from</span>
<span style="color: #666666; font-style: italic;"># an Active Directory export, but omit those that are listed in blacklist</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">\&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> , \\n<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> \; \\n <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> -F\: <span style="color: #ff0000;">'/(SMTP|smtp):/ {printf(&quot;%s\tOK\n&quot;,$2)}'</span> <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #660033;">-f</span> blacklist <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$2</span></pre></div></div>

	<p>Wenn man sich das Script aus dem Buch anschaut, dann findet man schnell den Fehler — nach der Korrektur sieht das Script so aus:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Extract all Adresses that start with SMTP or smtp from</span>
<span style="color: #666666; font-style: italic;"># an Active Directory export, but omit those that are listed in blacklist</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">\&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> , \\n<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> \; \\n <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> -F\: <span style="color: #ff0000;">'/^proxyAddresses: (SMTP|smtp):/ {printf(&quot;%s\tOK\n&quot;,$3)}'</span> <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #660033;">-f</span> blacklist <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$2</span></pre></div></div>

	<p>Die Email-Adressen, welche man nicht in der Tabelle haben möchte, schreibt man in eine Datei <code>blacklist</code>. Meine <code>blacklist</code> sieht so aus:</p>
	<blockquote><p>SystemMailbox<br />
Administrator<br />
Default<br />
exchangeV1<br />
globalevents<br />
internal<br />
KontaktevonEXAMPLE<br />
EXAMPLE<br />
EXAMPLE-Archiv<br />
OABVersion2<br />
OABVersion3a<br />
Offlineadressbuch-firstadministrativegroup<br />
PublicFolder08275515@example.de<br />
PublicFolder94568143@example.de<br />
schema-root</p></blockquote>
	<p>Wenn man jetzt das Script ausführt</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>extract_valid_recipient <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span>recipient.txt <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span>relay_recipient</pre></div></div>

	<p>So sieht das Ergebnis (<code>less /home/exchange/relay_recipients</code>)  dann so aus:</p>
	<blockquote><p>user1@example.de^M         OK<br />
useruser2@example.de^M         OK<br />
user2@example.de^M         OK<br />
Administrator@example.de^M         OK</p></blockquote>
	<p>Wie man sieht hat debian Probleme mit dem DOS-Zeilenumbruch. Um diesen Unix-Konform geradezubiegen installiert man sich das Paket <em>tofrodos</em>, welches den Befehl <em>dos2unix</em> mit sich bringt.</p>
	<p><span style="text-decoration: line-through;">Mit einem</span><br />
<span style="text-decoration: line-through;">dos2unix relay_recipients</span><br />
<span style="text-decoration: line-through;">wandelt man die Liste um und Voilá!</span></p>
	<p>Das ist natürlich falsch. Man muß die DOS-Zeilenumbrüche in der Original-Datei <em>recipient.txt</em> schon löschen und kann anschließend die Datei durch den Filter schicken.</p>
	<p>(Wer es komplizierter mag, der nehme den Befehl <em>flip</em>. Eine Erklärung dazu findet er <a href="http://www.debianadmin.com/flip-convert-text-file-line-endings-between-unix-and-dos-formats.html">hier</a>.)</p>
	<p>Jetzt wandeln wir die Datei in eine Postfix-Datenbank um</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">postmap <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span>relay_recipients</pre></div></div>

	<p>und kopieren wir die Datei in das postfix-Verzeichnis</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span>relay_recipients.db <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>relay_recipients.db</pre></div></div>

	<p>Wichtig ist der Hinweis im Buch, das die Datenbank-Datei im Home-Verzeichnis unseres exchange-Users erstellt und anschließend kopiert wird, da es beim Fehlschlagen des <em>postmap</em>–Befehls ansonsten keine <code>relay_recipients.db</code> im postfix-Verzeichnis geben und Postfix seinen Betrieb einstellen würde.</p>
	<p>Eingebunden in postfix wird es mit einem Eintrag in der /etc/postfix/main.cf</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">relay_recipient_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>relay_recipients</pre></div></div>

	<p>Jetzt kann man, wenn man es möchte, natürlich das Ganze noch automatisieren und in Scripte packen, dazu noch als Taskplaner/cron ausführen lassen. Aber das kommt später.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/05/25/debian-postfix-und-relay_recipient_maps-vom-exchange-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>debian &#124; postfix und relay_recipient_maps vom Exchange (I)</title>
		<link>http://controlc.de/2009/05/24/debian-postfix-und-relay_recipient_maps-vom-exchange-i/</link>
		<comments>http://controlc.de/2009/05/24/debian-postfix-und-relay_recipient_maps-vom-exchange-i/#comments</comments>
		<pubDate>Sun, 24 May 2009 10:52:48 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[spamschutz]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=451</guid>
		<description><![CDATA[Nachdem ich im Kapitel »Mail-Gateways« aus dem Buch Postfix — Einrichtung, Betrieb und Wartung gelesen habe, wie man eine Empfängerliste auf dem Exchange exportiert und in postfix einbindet habe ich mich mal dran gemacht das zu realisieren. Die Bemühungen kommen daher, das regelmäßig Versuche gestartet werden auf die Email-Adresse micha AT makomi DE einzuliefern — [...]]]></description>
			<content:encoded><![CDATA[	<p>Nachdem ich im Kapitel »Mail-Gateways« aus dem Buch <a href="http://www.postfix-buch.com/">Postfix — Einrichtung, Betrieb und Wartung</a> gelesen habe, wie man eine Empfängerliste auf dem Exchange exportiert und in postfix einbindet habe ich mich mal dran gemacht das zu realisieren. Die Bemühungen kommen daher, das regelmäßig Versuche gestartet werden auf die Email-Adresse micha AT makomi DE einzuliefern — eine Adresse die bei mir gar nicht existiert. Nachdem ich mal die Suchmaschine meines Vertrauens mit der »ominösen« Emailadresse gefüttert habe war klar: Da hat jemand die Adresse in einem Forum angegeben und die Betreiber hat nix Besseres zu tun, als die Profile öffentlich zu machen.<br />
<span id="more-451"></span><br />
Nun, eine erste Mail an den Admin hat keine Reaktion vorgerufen, also selber nach Lösungen suchen. Die Lösung steht in dem obigen Buch — übrigens sehr zu empfehlen.</p>
	<p>Jetzt aber zur Realisierung:</p>
	<p>Zuerst muß auf dem Exchange die aktuelle Email-Adressenliste generiert werden. Die Daten sind schon alle im Active Directory vorhanden, man muß sie da nur rausbekommen. Das geht mit Boardmitteln, aber der Reihe nach. Als Erstes lohnt es sich für den Austausch der Listen ein eigenes Verzeichnis anzulegen:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> c:\mailgw</pre></div></div>

	<p>Dann wird die Liste extrahiert:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ldifde <span style="color: #660033;">-m</span> <span style="color: #660033;">-n</span> <span style="color: #660033;">-g</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;C:\Mailgw<span style="color: #000099; font-weight: bold;">\r</span>ecipient.txt&quot;</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;(mailnickname=*)&quot;</span> <span style="color: #660033;">-l</span> proxyAddresses</pre></div></div>

	<p>Ein kurze Erklärung zu den Parametern:</p>
	<blockquote><p>–g              Deaktiviert die seitenweise Suche.<br />
–m              Aktiviert die SAM-Logik beim Export.<br />
–n              Exportiert keine Binärwerte.<br />
–f Dateiname    Dateiname für die Eingabe bzw. Ausgabe.<br />
–r Filter       LDAP-Suchfilter (Standard: »(objectClass=*)«).<br />
–l Liste        Liste der Attribute (durch Komma getrennt), nach denen bei<br />
der LDAP-Suche gesucht wird.</p></blockquote>
	<p>Das Komplizierteste ist nun der Datenaustausch vom Exchange-Server zum Mail-Gateway. Um dies zu bewältigen muß man dem Exchange-Server zuerst beibringen, wie man per Secure Copy (kurz SCP) Dateien verschicken kann. Es gibt verschiedene Programme dafür, am bekanntesten ist aber als Kommandozeilentool <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTYs PSCP</a>. Wir benötigen die beiden Programme <em>pscp.exe</em> und <em>puttygen.exe</em>.</p>
	<p>Nun legen wir zuerst auf dem debian-Server einen neuen Benutzer an, der nur für den Transfer der Listen auf das Mail-Gateway verantwortlich ist:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">useradd <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-m</span> exchange</pre></div></div>

	<p>Im Gegensatz zu den Angaben im Buch mußte ich bei debian Lenny das Homeverzeichnis explizit mit angeben, da Lenny anscheinend das nicht selbstständig anlegt.</p>
	<p>Nachdem der Benutzer existiert geben wir ihm zuerst einmal ein Passwort:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">passwd</span> exchange</pre></div></div>

	<p>Anschließend generieren wir ein SSH-Schlüsselpaar, damit der Dateitransfer ohne die Eingabe von Passwörtern erfolgen kann:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - exchange
<span style="color: #7a0874; font-weight: bold;">cd</span> ~
<span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa</pre></div></div>

	<p>Bei der Nachfrage nach einer Passphrase bitte nix eingeben. Nur wenn hier kein Passwort eingegeben wird, kann der Dateiaustausch wirklich vollautomatisch erfolgen.</p>
	<pre>Generating public/private rsa key pair.
Enter file in which to save the key (/home/exchange/.ssh/id_rsa):
Created directory '/home/exchange/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/exchange/.ssh/id_rsa.
Your public key has been saved in /home/exchange/.ssh/id_rsa.pub.
The key fingerprint is:
ba:90:03:e8:06:20:5f:30:00:52:a9:11:c6:2e:ae:10 exchange@example.de
The key's randomart image is:
+--[ RSA 2048]----+
|&amp;+..             |
|=*.              |
|.o+              |
|.+ +             |
|. o +   S        |
|E. . . o         |
|..    =          |
|o      +         |
|.     .          |
+-----------------+</pre>
	<p>Es werden nun zwei neue Dateien im Unterverzeichnis <em>.ssh</em> erstellt: <em>id_rsa</em> und<em> id_rsa.pub</em></p>
	<p>Damit der Server weiß, das der Benutzer <em>exchange</em> mit Hilfe von Schlüsseln auf den Server zugreifen darf, muß man noch den Inhalt der Datei <em>id_rsa</em> an die Datei <em>~/.ssh/authorized_keys</em> angehängt werden. Dazu gibt man</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

	<p>ein und gibt mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">644</span> authorized_keys</pre></div></div>

	<p>der Datei die richtigen Rechte.</p>
	<p>Nun muß der private Schlüssel des Paares auf einem sicheren Weg zum Exchange-Server kommen. Dazu nutzen wir gleich die <em>pscp.exe</em>.</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pscp exchange<span style="color: #000000; font-weight: bold;">@</span>mail.example.de:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa .</pre></div></div>

	<p>Ich denke der Syntax ist klar. Natürlich müssen wir uns jetzt mit einem Passwort authentifizieren — genau mit dem, welches wir oben vergeben haben.</p>
	<p>Um die Schlüsseldatei nutzen zu können müssen wir sie in ein PuTTY-verträgliches Format wandeln. Dazu nutzen wir die von PuTTY mitgelieferte <em>puttygen.de</em></p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">puttygen c:\mailgw\id_rsa</pre></div></div>

	<p>es öffnet sich eine GUI</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/05/puttygen-1.png" class="floatbox" rev="group:451 caption:`puttygen-1`"><img class="alignnone size-full wp-image-468" title="puttygen-1" src="http://controlc.de/wp-content/uploads/2009/05/puttygen-1.png" alt="puttygen-1" width="266" height="150" /></a></p>
	<p>Nach eine Klick auf OK öffnet sich der PuTTY Key Generator-Dialog:</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/05/puttygen-2.png" class="floatbox" rev="group:451 caption:`puttygen-2`"><img class="alignnone size-medium wp-image-469" title="puttygen-2" src="http://controlc.de/wp-content/uploads/2009/05/puttygen-2-300x287.png" alt="puttygen-2" width="300" height="287" /></a></p>
	<p>Hier kann man im Feld <em>Key comment</em> dem konvertierten Schlüssel einen Namen wegen und anschließend <em>Save private key</em> drücken.</p>
	<p><a href="http://controlc.de/wp-content/uploads/2009/05/puttygen-3.png" class="floatbox" rev="group:451 caption:`puttygen-3`"><img class="alignnone size-full wp-image-470" title="puttygen-3" src="http://controlc.de/wp-content/uploads/2009/05/puttygen-3.png" alt="puttygen-3" width="260" height="117" /></a></p>
	<p>Aufgrund der leeren Passphrase wird hier eine Warnung ausgegeben, was aber ok ist.</p>
	<p>Nun können wir mit dem eben erstellten/konvertierten Key eine verschlüsselte Verbindung zu unserem Mail-Gateway aufnehmen</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pscp <span style="color: #660033;">-i</span> mail.example.de.ppk recipient.txt exchange<span style="color: #000000; font-weight: bold;">@</span>mail.example.de:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>exchange<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

	<p>Nachdem das geklappt hat, können wir dem Benutzer <em>exchange</em> auf dem Mail-Gateway das Passwort wegnehmen — dann ist ein einloggen nur noch mit dem Key möglich.</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">usermod <span style="color: #660033;">-L</span> exchange</pre></div></div>

	<p><em><strong>Weiter geht es im <a href="http://controlc.de/2009/05/25/debian-postfix-und-relay_recipient_maps-vom-exchange-ii/">zweiten Teil</a><span style="text-decoration: line-through;">, der demnächst erscheint</span>.</strong></em>
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/05/24/debian-postfix-und-relay_recipient_maps-vom-exchange-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

