<?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: ghodbani saoussen</title>
    <description>The latest articles on DEV Community by ghodbani saoussen (@ghodbani_saoussen_2a58a20).</description>
    <link>https://dev.to/ghodbani_saoussen_2a58a20</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%2F3963390%2F7723528f-d1e6-42d3-b27d-9462e5116b19.jpg</url>
      <title>DEV Community: ghodbani saoussen</title>
      <link>https://dev.to/ghodbani_saoussen_2a58a20</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ghodbani_saoussen_2a58a20"/>
    <language>en</language>
    <item>
      <title>How to Renew an Apache SSL Certificate with Restricted SSH and WinSCP Permissions</title>
      <dc:creator>ghodbani saoussen</dc:creator>
      <pubDate>Mon, 01 Jun 2026 21:23:12 +0000</pubDate>
      <link>https://dev.to/ghodbani_saoussen_2a58a20/how-to-renew-an-apache-ssl-certificate-with-restricted-ssh-and-winscp-permissions-56e9</link>
      <guid>https://dev.to/ghodbani_saoussen_2a58a20/how-to-renew-an-apache-ssl-certificate-with-restricted-ssh-and-winscp-permissions-56e9</guid>
      <description>&lt;p&gt;When managing production enterprise infrastructure, you rarely have direct root access via SFTP or SSH for security reasons. Instead, you often have to navigate multi-layered permissions—logging in as a standard user, transferring files locally, and escalating privileges via CLI to finalize configurations.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will walk through the step-by-step procedure to safely renew an Apache SSL certificate under a restricted environment where WinSCP access is limited to a non-root user (sysops), requiring command-line intervention to complete the installation.&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;br&gt;
A target Apache web server (CentOS/RHEL-based configuration using /etc/httpd/).&lt;/p&gt;

&lt;p&gt;A standard user account (sysops) with sudo privileges.&lt;/p&gt;

&lt;p&gt;The new SSL certificate (.crt) and CA bundle/chain file ready on your local machine.&lt;/p&gt;

&lt;p&gt;Step 1: Backup Existing Certificates&lt;br&gt;
Before making any changes to production security files, always back up the working configuration.&lt;/p&gt;

&lt;p&gt;Access the server via PuTTY using the sysops account, and switch to the root user or use sudo to create a backup of your existing keys:&lt;/p&gt;

&lt;p&gt;sudo cp /etc/httpd/server.crt /etc/httpd/server.crt.bak&lt;br&gt;
sudo cp /etc/httpd/server.key /etc/httpd/server.key.bak&lt;/p&gt;

&lt;p&gt;Step 2: Stage the New Certificates via WinSCP&lt;br&gt;
Because your WinSCP session cannot log in directly as root, you must stage the files in a directory your user owns.&lt;/p&gt;

&lt;p&gt;Open WinSCP and log in using your sysops credentials.&lt;/p&gt;

&lt;p&gt;Upload your new certificate files (nouveau_certificat.crt and nouveau_certificat_chain.pem) directly into your home directory: /home/sysops/.&lt;/p&gt;

&lt;p&gt;Step 3: Install and Replace the Certificates&lt;br&gt;
Now, return to your terminal session (PuTTY) to move the files from your staging directory to the protected Apache directory using elevated privileges.&lt;/p&gt;

&lt;h1&gt;
  
  
  Copy the new primary certificate
&lt;/h1&gt;

&lt;p&gt;sudo cp /home/sysops/nouveau_certificat.crt /etc/httpd/server.crt&lt;/p&gt;

&lt;h1&gt;
  
  
  Copy the new certificate chain / CA bundle
&lt;/h1&gt;

&lt;p&gt;sudo cp /home/sysops/nouveau_certificat_chain.pem /etc/httpd/server-ca.crt&lt;/p&gt;

&lt;p&gt;Step 4: Verify Permissions and Ownership&lt;br&gt;
Apache requires strict file permissions to ensure private keys are not exposed. Navigate to the directory and verify that the file owners, groups, and permissions match your organizational standards:&lt;/p&gt;

&lt;p&gt;cd /etc/httpd/&lt;br&gt;
ls -l&lt;/p&gt;

&lt;p&gt;Ensure your output aligns with secure permissions (e.g., the private key should ideally be restricted to chmod 600 or 400 owned by root):&lt;/p&gt;

&lt;p&gt;-rw-r--r--. 1 root root   4907 Oct 28 2024 server-ca.crt&lt;br&gt;
-rw-r--r--. 1 root root   2313 Oct  9 12:30 server.crt&lt;br&gt;
-rw-------. 1 root root   1704 Oct  9 12:30 server.key&lt;/p&gt;

&lt;p&gt;Step 5: Test the Apache Configuration&lt;br&gt;
Never restart a production web server without testing the configuration first. A syntax error or mismatched key pair can cause downtime.&lt;/p&gt;

&lt;p&gt;Run the configuration test utility:&lt;br&gt;
apachectl configtest&lt;/p&gt;

&lt;p&gt;Ensure the output returns Syntax OK before proceeding.&lt;/p&gt;

&lt;p&gt;Step 6: Restart and Verify the Service&lt;br&gt;
Once the configuration test passes successfully, restart Apache to apply the new SSL certificates and check the service status:&lt;/p&gt;

&lt;h1&gt;
  
  
  Restart the Apache service
&lt;/h1&gt;

&lt;p&gt;sudo systemctl restart httpd&lt;/p&gt;

&lt;h1&gt;
  
  
  Verify the service is active and running
&lt;/h1&gt;

&lt;p&gt;sudo systemctl status httpd&lt;/p&gt;

&lt;h1&gt;
  
  
  Restart the Apache service
&lt;/h1&gt;

&lt;p&gt;sudo systemctl restart httpd&lt;/p&gt;

&lt;h1&gt;
  
  
  Verify the service is active and running
&lt;/h1&gt;

&lt;p&gt;sudo systemctl status httpd&lt;/p&gt;

&lt;p&gt;Your Apache server is now successfully serving the newly renewed SSL certificate!&lt;/p&gt;

</description>
      <category>infrastructure</category>
      <category>linux</category>
      <category>security</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
