Ask Your Question
1

How can I use Bash to download and add a salt string into the wp-config.php file of WordPress?

asked 2021-06-25 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-12-31 21:00:00 +0000

huitzilopochtli gravatar image

You can use the following Bash script to download WordPress and add a salt string into the wp-config.php file:

#!/bin/bash

# Download WordPress
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

# Generate new salts
SALT=$(curl -L https://api.wordpress.org/secret-key/1.1/salt/)

# Update wp-config.php file
sed -i "/^define('AUTH_KEY'/c\define('AUTH_KEY',         '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('SECURE_AUTH_KEY'/c\define('SECURE_AUTH_KEY',  '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('LOGGED_IN_KEY'/c\define('LOGGED_IN_KEY',    '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('NONCE_KEY'/c\define('NONCE_KEY',        '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('AUTH_SALT'/c\define('AUTH_SALT',        '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('SECURE_AUTH_SALT'/c\define('SECURE_AUTH_SALT', '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('LOGGED_IN_SALT'/c\define('LOGGED_IN_SALT',   '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php
sed -i "/^define('NONCE_SALT'/c\define('NONCE_SALT',       '$(echo [YOUR_SALT_STRING_HERE])');" wordpress/wp-config.php

# Move WordPress files into web server
sudo mv wordpress/* /var/www/html/

# Set correct permissions
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Replace [YOUR_SALT_STRING_HERE] with your actual salt string.

After running this script, your WordPress site will have a new salt string added to its wp-config.php file, which enhances the security of user passwords and other sensitive data stored in the database.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-25 11:00:00 +0000

Seen: 8 times

Last updated: Dec 31 '22