<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rupesh Sharma</title>
    <description>The latest articles on DEV Community by Rupesh Sharma (@rupesharma).</description>
    <link>https://dev.to/rupesharma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2769193%2F0c2da7e1-6924-46aa-bec9-d73f5331d606.jpeg</url>
      <title>DEV Community: Rupesh Sharma</title>
      <link>https://dev.to/rupesharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rupesharma"/>
    <language>en</language>
    <item>
      <title>Transform Your Linux Security: Activate MFA for SSH with Google Authenticator for Unbreakable Protection</title>
      <dc:creator>Rupesh Sharma</dc:creator>
      <pubDate>Mon, 27 Jan 2025 07:32:46 +0000</pubDate>
      <link>https://dev.to/rupesharma/transform-your-linux-security-activate-mfa-for-ssh-with-google-authenticator-for-unbreakable-2ak0</link>
      <guid>https://dev.to/rupesharma/transform-your-linux-security-activate-mfa-for-ssh-with-google-authenticator-for-unbreakable-2ak0</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Enforcing MFA (Multi-Factor Authentication) on a Linux system for authenticating is important for enhancing security. This blog will guide you to set up MFA for your Linux system by providing secure SSH(Secure Shell) connection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaxihqkzsyhtx0nctm9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaxihqkzsyhtx0nctm9p.png" alt="Image description" width="686" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites for this setup&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;  A Linux system&lt;/li&gt;
&lt;li&gt;    Google-Authenticator App on smartphone.&lt;/li&gt;
&lt;li&gt;    openssh ( If you don’t have openSSH, install using sudo apt install openssh-server)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now the we know the prerequisites to enable MFA on linux, let’s dive into the steps configre it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Update and Install Google-Authenticator&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update -y

sudo apt install libpam-google-authenticator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1av4sh3b30gqfi1pg5n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1av4sh3b30gqfi1pg5n0.png" alt="Update and install google-authenticator on linux" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Configure Google Authenticator for Users&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;google-authenticator&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After you execute the above command, you a QR code will be generated, upon scanning it will redirect you to your Google Authenticator app to save key for the user you are logged into. Make sure you have logged in to your Google Authenticator in Phone. You will be asked to enter the code from your google authenticator.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7mlpcy3i3ss02bg5dk8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7mlpcy3i3ss02bg5dk8.png" alt="google authenticator" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will be asked to configure the Authenticator with following Questions;&lt;br&gt;
_&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do you want authentication tokens to be time-based (y/n)
_
If you choose “y”: OTPs will be time-based, changing every 30 seconds, ensuring higher security.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you choose “n”: OTPs won’t be time-based, which can lower security as the token remains valid longer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended : yes&lt;/strong&gt;&lt;br&gt;
_&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do you want me to update your “/home/vagrant/.google_authenticator” file? (y/n)_&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you choose “y”: The .google_authenticator file will be updated with the secret key, enabling Google Authenticator to work properly.&lt;/p&gt;

&lt;p&gt;If you choose “n”: The .google_authenticator file won’t be updated, and the changes will not take effec&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended : yes&lt;/strong&gt;&lt;br&gt;
_&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do you want to disallow multiple uses of the same authentication token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n)_&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you choose “y”: OTPs can only be used once, preventing attackers from reusing the same token in multiple login attempts.&lt;/p&gt;

&lt;p&gt;If you choose “n”: OTPs can be reused, which may increase the risk of successful brute-force attacks or replay attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended : yes&lt;/strong&gt;&lt;br&gt;
_&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By default, a new token is generated every 30 seconds by the mobile app.In order to compensate for possible time-skew between the client and the server,we allow an extra token before and after the current time. This allows for a time skew of up to 30 seconds between authentication server and client. If you experience problems with poor time synchronization, you can increase the window from its default size of 3 permitted codes (one previous code, the current code, the next code) to 17 permitted codes (the 8 previous codes, the current code, and the 8 next codes). This will permit for a time skew of up to 4 minutesbetween client and server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do you want to do so? (y/n)_&lt;/p&gt;

&lt;p&gt;If you choose “y”: A larger time window for OTP validation will be allowed (up to 4 minutes) to account for time differences between the client and server.&lt;/p&gt;

&lt;p&gt;If you choose “n”: The default 30-second window for OTP validation will be used, which is more secure but requires precise time synchronization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended : no&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;5. If the computer that you are logging into isn’t hardened against brute-force login attempts, you can enable rate-limiting for the authentication module. By default, this limits attackers to no more than 3 login attempts every 30s. Do you want to enable rate-limiting? (y/n)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you choose “y”: Rate-limiting will be enabled, restricting attackers to 3 login attempts every 30 seconds, slowing down brute-force attacks.&lt;/p&gt;

&lt;p&gt;If you choose “n”: No rate-limiting will be applied, making the system more vulnerable to brute-force login attempts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended : yes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Felbx4tockudj9b0ccaa3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Felbx4tockudj9b0ccaa3.png" alt="Google Authenticator configuration" width="800" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In short, For security, it’s recommended to choose “y” for time-based authentication, updating the file, disallowing token reuse, and enabling rate-limiting, and “n” for 4th Question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:Integrate Google Authenticator with PAM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Edit PAM configuration and add given line at the top of the pam config file: auth required &lt;em&gt;pam_google_authenticator.so&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo nano /etc/pam.d/sshd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Configure SSH config file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Edit the &lt;em&gt;/etc/sshd/sshd_config&lt;/em&gt; and add the given lines if they already exits just type “yes” to enable it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ChallengeResponseAuthentication yes

KbdInteractiveAuthentication yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo11tnikeqmjkb8piqzr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo11tnikeqmjkb8piqzr8.png" alt="Editing sshd_config file" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Restarting the sshd service to reload new configuration&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh28daigbsl7j85dalu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuh28daigbsl7j85dalu9.png" alt="Restarting sshd service after configuration" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 5: Verifying the implementation of MFA on Linux server.&lt;/p&gt;

&lt;p&gt;Now when you ssh into Linux Server you have to enter the verification code from Google-Authenticator App on your Phone. And then when you enter the correct password for the user you are logging in, you get the access to the Linux server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1rsloiznkelwzhzmxz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1rsloiznkelwzhzmxz6.png" alt="Verifying the MFA implementation on Linux server" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Attack that can be prevented using MFA for SSH&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Brute Force Attacks: Rate-limiting restricts login attempts, making it difficult for attackers to guess SSH passwords.&lt;/li&gt;
&lt;li&gt;Credential Stuffing: MFA ensures that even if an attacker obtains SSH credentials, they can’t access the system without the second factor.&lt;/li&gt;
&lt;li&gt;Man-in-the-Middle (MITM) Attacks: Time-based OTPs prevent attackers from intercepting and replaying SSH authentication tokens.&lt;/li&gt;
&lt;li&gt;Replay Attacks: Disallowing token reuse ensures that intercepted SSH tokens can’t be reused for subsequent logins.&lt;/li&gt;
&lt;li&gt;Password Guessing: MFA adds an additional layer of security, making it harder for attackers to access the system through SSH.&lt;/li&gt;
&lt;li&gt;Phishing Attacks: Even if SSH login credentials are phished, the attacker still requires the OTP to successfully authenticate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Securing SSH access is crucial for protecting your Linux systems from cyberattacks. By enabling MFA with Google Authenticator, you add an extra layer of security that safeguards against brute force, phishing, and other unauthorized access attempts. With this easy-to-follow guide, you can significantly enhance your system’s protection and stay ahead of potential threats. Prioritize your Linux security today and make your SSH connections safer than ever!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>cybersecurity</category>
      <category>mfa</category>
      <category>secops</category>
    </item>
    <item>
      <title>Master File Transfers and Backups with Rsync and SCP: A Beginner’s Guide</title>
      <dc:creator>Rupesh Sharma</dc:creator>
      <pubDate>Mon, 27 Jan 2025 07:19:04 +0000</pubDate>
      <link>https://dev.to/rupesharma/master-file-transfers-and-backups-with-rsync-and-scp-a-beginners-guide-106o</link>
      <guid>https://dev.to/rupesharma/master-file-transfers-and-backups-with-rsync-and-scp-a-beginners-guide-106o</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Managing file transfer and backups are en essential skill everyone should must learn. Two most popular tools for this purpose are scp and rsync. While scp is simple to securely send or receive file to and from remote server to local server, rsync is popular for data backup, data synchronization and server mirroring. This blog will help you understand how to get started with both the tools and choose which one to use wisely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftlfvhz400d0dkuknedsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftlfvhz400d0dkuknedsy.png" alt="Image description" width="308" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. rsync:&lt;/strong&gt;&lt;br&gt;
rsync is a fast and flexible tool to copy and synchronize files and directories, either locally or between systems. It is commonly used for backups, mirroring, and transferring data efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. SCP (Secure Copy Protocol):&lt;/strong&gt;&lt;br&gt;
A simple tool for securely copying files between systems over SSH. It encrypts data during transit, ensuring security. Best for quick, straightforward file transfers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rsync:&lt;/strong&gt;&lt;br&gt;
For syncing large datasets efficiently.&lt;br&gt;
When saving bandwidth is important.&lt;br&gt;
To mirror directories with file attributes preserved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SCP:&lt;/strong&gt;&lt;br&gt;
For secure, quick file transfers.&lt;br&gt;
When simplicity is more important than advanced features.&lt;br&gt;
For smaller or occasional transfers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing rsync&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;rsync is by default installed on Linux system, in case rsync is not available try installing using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo apt install rsync&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Most useful rsync option:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;-a : Archive Mode for recursive copying, preserving permissions,timestamps, and other attributes&lt;/li&gt;
&lt;li&gt;-v : Verbose Mode, shows details of what happening&lt;/li&gt;
&lt;li&gt;-z : Compress Mode, allows to compress the file during transfer to save the bandwidth.&lt;/li&gt;
&lt;li&gt;-h : Makes numbers easier to read (e.g., file sizes in KB, MB)&lt;/li&gt;
&lt;li&gt;-P : Displays the progress of the file transfer.&lt;/li&gt;
&lt;li&gt;-r : Recursively copies files and directories, but doesn’t preserve timestamps or permissions.&lt;/li&gt;
&lt;li&gt; --dry-run : Allow user to simulate the rsync transfer without copying or syncing the files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3f784zq9b1bj36sp76r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3f784zq9b1bj36sp76r.png" alt="rsync dry-run test" width="800" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: You will need to have the username ,password and IP address of the remove server where you want to sync,copy or mirror your files using rsync and scp.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rsync for file Transfer&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Local Transfer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5m3l35hdusexj4ez9yo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5m3l35hdusexj4ez9yo.png" alt="rsync for local transfer locally." width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remote Transfer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbpmbp03po1ppfpgp65m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbpmbp03po1ppfpgp65m.png" alt="rsync for transferring file remotely from local server." width="800" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmgzitazcmb9jzvsqyi1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmgzitazcmb9jzvsqyi1d.png" alt="verifying the if file has been transferred to remote backup-server." width="695" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remote Synchronization&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg9pcqmi4jrrc9oypdnw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg9pcqmi4jrrc9oypdnw.png" alt="Modifying the backup-file on local server." width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcrm27zo7wvbbw73ewxqe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcrm27zo7wvbbw73ewxqe.png" alt="synchronizing file from local to remote backup-server." width="800" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20fg4zooextg7bykk5ve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20fg4zooextg7bykk5ve.png" alt="Verifying file synchronization on remote backup-server." width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using --backup-dir for enhanced backup system:&lt;/p&gt;

&lt;p&gt;This option will allow the user to back up the file and also keep the record of previous version of the file for effective backup system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19aw7xe03g5y70adt6l9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19aw7xe03g5y70adt6l9.png" alt="Edit the backup-file" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3qdsn2oh48rnb5yerjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3qdsn2oh48rnb5yerjv.png" alt="Taking backup of modified backup-file" width="800" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the remote backup-server it can be seen that there are two file recorded, on /Archive folder a back-file.txt is create which hold the previous version of the backup-file. On the other hand, there is also a recent backupfile updated with recent changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxt87o6hqf069sfeifsj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frxt87o6hqf069sfeifsj.png" alt="verifying the backup and previous file are recorded for effective backup." width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Converting the command into simple backup script.
&lt;/h2&gt;

&lt;p&gt;This is the simple script to backup file with rsync.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
#!/bin/bash
#@Author: Rupesh Sharma

SOURCE_FILE="/home/vagrant/backup/backup-file.txt"
BACKUP_SERVER="vagrant@192.168.56.20:/home/vagrant/rsync"
ARCHIVE_DIR="/home/vagrant/rsync/Archive"
DATE_TIME=$(date +%Y-%m-%d-%H:%M:%S)
rsync -vazh --backup-dir="$ARCHIVE_DIR/$DATE_TIME" "$SOURCE_FILE" "$BACKUP_SERVER"

echo "Backup Completed for : $DATE_TIME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxny7fgfuahg2ta17p1aa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxny7fgfuahg2ta17p1aa.png" alt="Backup script file" width="772" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy53n1engit987i8xuo7q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy53n1engit987i8xuo7q.png" alt="Executing the script" width="586" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoaq3ecro5wejprwk3jx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoaq3ecro5wejprwk3jx.png" alt="verifying script otuput." width="669" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SCP(Secure Copy Protocol)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Similar to rsync SCP is by default installed on Linux system, in case SCP is not available try installing using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo apt install openssh-client&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7vwsms7s34gsa8ss3zx7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7vwsms7s34gsa8ss3zx7.png" alt="Installing SCP" width="675" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Transferring file to Remote server&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Transferring file using scp for local system to remote system.&lt;br&gt;
verifying the file transferred from local to remote system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvj0w5bh0318crxq69956.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvj0w5bh0318crxq69956.png" alt="Transferring file using scp for local system to remote system." width="800" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60oeeltsbgks7ejj18rm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60oeeltsbgks7ejj18rm.png" alt="verifying the file transferred from local to remote system." width="800" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pulling file from Remote server to local server using local server.
Pulling file from Remote server to local server using local server&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqr4tb6uxfa4prx76g9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqr4tb6uxfa4prx76g9v.png" alt="Pulling file from Remote server to local server using local server" width="800" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;To conclude with, both rsync and scp are indispensable tools for file transfer and synchronization. While scp is ideal for simple, secure transfers, rsync excels in efficiency, making it perfect for backups and large-scale synchronizations.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>cybersecurity</category>
      <category>ubuntu</category>
      <category>security</category>
    </item>
  </channel>
</rss>
