<?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>lsyncd ssh with public key Archives - CNERIS</title>
	<atom:link href="https://cneris.com/en/tag/lsyncd-ssh-with-public-key-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://cneris.com/en/tag/lsyncd-ssh-with-public-key-en/</link>
	<description></description>
	<lastBuildDate>Mon, 26 Aug 2024 08:40:12 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Step-by-Step Guide to Configuring Lsyncd with Public Key Authentication</title>
		<link>https://cneris.com/en/step-by-step-guide-to-configuring-lsyncd-with-public-key-authentication/</link>
					<comments>https://cneris.com/en/step-by-step-guide-to-configuring-lsyncd-with-public-key-authentication/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 26 Aug 2024 08:40:12 +0000</pubDate>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Dedicated servers]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[lsyncd ssh with public key]]></category>
		<category><![CDATA[lsyncd with public key]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2172</guid>

					<description><![CDATA[<p>1. Install Lsyncd First, install Lsyncd on the main server where you want to set up synchronization. For Debian/Ubuntu-based systems: sudo apt-get update sudo apt-get install lsyncd For Red Hat/CentOS-based systems: sudo yum install epel-release sudo yum install lsyncd 2. Generate SSH Public Key Generate an SSH key pair (public and private keys) on the [...]</p>
<p>The post <a href="https://cneris.com/en/step-by-step-guide-to-configuring-lsyncd-with-public-key-authentication/">Step-by-Step Guide to Configuring Lsyncd with Public Key Authentication</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h4>1. <strong>Install Lsyncd</strong></h4>
<p>First, install Lsyncd on the main server where you want to set up synchronization.</p>
<p>For Debian/Ubuntu-based systems:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">sudo apt-get update<br />
sudo apt-get install lsyncd<br />
</code></div>
</div>
<p>For Red Hat/CentOS-based systems:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">sudo yum install epel-release<br />
sudo yum install lsyncd<br />
</code></div>
</div>
<h4>2. <strong>Generate SSH Public Key</strong></h4>
<p>Generate an SSH key pair (public and private keys) on the main server (Server A).</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">ssh-keygen -t rsa -b 4096<br />
</code></div>
</div>
<p>Follow the prompts and save the keys in the default directory (<code>~/.ssh/id_rsa</code> for the private key and <code>~/.ssh/id_rsa.pub</code> for the public key).</p>
<h4>3. <strong>Copy the Public Key to the Remote Server</strong></h4>
<p>Copy the generated public key to the destination server (Server B) using the following command:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">ssh-copy-id user@remote_server<br />
</code></div>
</div>
<p>This command will add the public key to the <code>~/.ssh/authorized_keys</code> file on the remote server, allowing passwordless authentication.</p>
<h4>4. <strong>Verify SSH Passwordless Connection</strong></h4>
<p>Verify that you can connect to the remote server without needing to enter a password:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">ssh user@remote_server<br />
</code></div>
</div>
<p>If the connection succeeds without asking for a password, the public key setup is working correctly.</p>
<h4>5. <strong>Configure the Lsyncd File</strong></h4>
<p>Edit or create the Lsyncd configuration file, usually located at <code>/etc/lsyncd/lsyncd.conf.lua</code>.</p>
<p>Configuration example:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md"></div>
<div class="overflow-y-auto p-4" dir="ltr">
<p>settings {<br />
logfile = &#8220;/var/log/lsyncd/lsyncd.log&#8221;,<br />
statusFile = &#8220;/var/log/lsyncd/lsyncd-status.log&#8221;,<br />
nodaemon = false,<br />
}</p>
<p>sync {<br />
default.rsyncssh,<br />
source = &#8220;/ruta/a/sincronizar/&#8221;,<br />
host = &#8220;usuario@servidor_remoto&#8221;,<br />
targetdir = &#8220;/ruta/remota/destino/&#8221;,<br />
rsyncOpts = {&#8220;-avz&#8221;},<br />
ssh = {<br />
port = 22,<br />
identityFile = &#8220;/home/tu_usuario/.ssh/id_rsa&#8221;<br />
}<br />
}</p>
</div>
</div>
<h4>6. <strong>Start Lsyncd</strong></h4>
<p>Start Lsyncd to begin synchronization:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">sudo lsyncd /etc/lsyncd/lsyncd.conf.lua<br />
</code></div>
</div>
<p>To ensure Lsyncd starts automatically when the server boots, you can enable it as a system service.</p>
<h4>7. <strong>Monitoring and Logs</strong></h4>
<p>Check Lsyncd logs to monitor its activity and ensure synchronization is occurring correctly:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash"><span class="hljs-built_in">tail</span> -f /var/log/lsyncd/lsyncd.log</code></div>
</div>
<p>The post <a href="https://cneris.com/en/step-by-step-guide-to-configuring-lsyncd-with-public-key-authentication/">Step-by-Step Guide to Configuring Lsyncd with Public Key Authentication</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/step-by-step-guide-to-configuring-lsyncd-with-public-key-authentication/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
