<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://turecki.net"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Michał Turecki - optimization</title>
 <link>https://turecki.net/tags/optimization</link>
 <description></description>
 <language>en</language>
<item>
 <title>How to run another SSH daemon on Amazon EC2 - on a different port</title>
 <link>https://turecki.net/second-sshd-on-ec2</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Running a separate SSH server only makes sense when a second SSHD will run using different settings. If settings are the same, port forwarding should be enough to just pass the traffic from one port to another:&lt;/p&gt;
&lt;pre&gt;iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 20202 -j REDIRECT --to-port 22&lt;/pre&gt;&lt;p&gt;where 20202 is the new port and 22 is the default SSH port.&lt;/p&gt;
&lt;p&gt;If SSHD settings should be separate, we need another sshd instance with a copy of current configuration files).&lt;/p&gt;
&lt;p&gt;Please remember to change the alternative ssh port number (20202) to a custom port.&lt;/p&gt;
&lt;pre&gt;ln -sf /usr/sbin/sshd /usr/sbin/alt_sshd
cat /etc/init.d/sshd | sed -e &#039;/^.*sshd-keygen\s*$/! s/\([/ &quot;]\)sshd/\1alt_sshd/&#039; -e &#039;s/^\(\s\+\$SSHD\)/\1 -f \/etc\/ssh\/alt_sshd_config/I&#039; &amp;gt;/etc/init.d/alt_sshd
cat /etc/ssh/sshd_config | sed -e &#039;s/^#*\s*\(pidfile.*\)sshd\.pid/\1alt_sshd.pid/I&#039; -e &#039;s/^#*\s*port\s\+[0-9]\+/Port 20202/I&#039; &amp;gt;/etc/ssh/alt_sshd_config
cp -na /etc/sysconfig/sshd /etc/sysconfig/alt_sshd
cp -na /etc/pam.d/sshd /etc/pam.d/alt_sshd
chkconfig --add alt_sshd&lt;/pre&gt;&lt;p&gt;After running the commands above, modify your new configuration file /etc/ssh/alt_sshd/config and start the sshd:&lt;/p&gt;
&lt;pre&gt;/etc/init.d/alt_sshd start&lt;/pre&gt;&lt;p&gt;The chkconfig command will ensure the alt_sshd will start automatically after system restart.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/tags/linux&quot;&gt;linux&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot;&gt;&lt;a href=&quot;/tags/ssh&quot;&gt;ssh&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/tags/optimization&quot;&gt;optimization&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 31 Oct 2014 11:15:18 +0000</pubDate>
 <dc:creator>Michał Turecki</dc:creator>
 <guid isPermaLink="false">21 at https://turecki.net</guid>
 <comments>https://turecki.net/second-sshd-on-ec2#comments</comments>
</item>
</channel>
</rss>
