{"id":712,"date":"2012-08-06T04:20:41","date_gmt":"2012-08-06T10:20:41","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=712"},"modified":"2026-03-27T00:49:44","modified_gmt":"2026-03-27T06:49:44","slug":"script-to-change-the-passwords-of-all-cpanel-accounts","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/script-to-change-the-passwords-of-all-cpanel-accounts\/","title":{"rendered":"How to Change All cPanel Account Passwords Using a Script"},"content":{"rendered":"\n<p>In certain situations such as security incidents, compromised accounts, or routine security maintenance, administrators may need to reset passwords for <strong>all cPanel accounts<\/strong> on a server.<\/p>\n\n\n\n<p>The following script helps automate the process by generating strong passwords and updating them for every cPanel and FTP account.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Create the Password Change Script<\/strong><\/h3>\n\n\n\n<p>Create a script file named <strong><code>changepass.sh<\/code><\/strong> using your preferred editor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi changepass.sh<\/code><\/pre>\n\n\n\n<p>Add the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/bash<br>ls -1 \/var\/cpanel\/users | while read user; do<br>pass=`&lt;\/dev\/urandom tr -dc \"A-Za-z0-9*-\/+.*=_\\|\\\\#\" | head -c16`<br>echo \"$user $pass\" &gt;&gt; new-pass.txt<br>\/scripts\/realchpass $user $pass<br>\/scripts\/ftpupdate<br>done<\/code><\/pre>\n\n\n\n<p>This script:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Generates secure random passwords<\/li>\n\n\n\n<li>Updates passwords for all cPanel users<\/li>\n\n\n\n<li>Syncs FTP account passwords<\/li>\n\n\n\n<li>Saves new credentials in a text file<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Set Execute Permission<\/strong><\/h3>\n\n\n\n<p>Make the script executable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x changepass.sh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Run the Script<\/strong><\/h3>\n\n\n\n<p>Execute the script using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sh changepass.sh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Output<\/strong><\/h3>\n\n\n\n<p>After execution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>All <strong>cPanel and FTP passwords<\/strong> will be updated.<\/li>\n\n\n\n<li>A file named <strong><code>new-pass.txt<\/code><\/strong> will be created containing usernames and newly generated passwords.<\/li>\n<\/ul>\n\n\n\n<p><strong>Important:<\/strong><br>Store the <code>new-pass.txt<\/code> file securely and delete it after distributing credentials to users.<\/p>\n\n\n\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n\n\n\n<p class=\"has-text-align-center\"><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><\/a><\/span><\/span><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In certain situations such as security incidents, compromised accounts, or routine security maintenance, administrators may need to reset passwords for all cPanel accounts on a server. The following script helps&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-712","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=712"}],"version-history":[{"count":6,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions"}],"predecessor-version":[{"id":16754,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions\/16754"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}