❌

Normal view

Received before yesterday

How to Setup SOCKS5 Proxy Server on Linux Using MicroSocks

14 June 2024 at 13:46

VPNs are popular these days, but many users still prefer using a SOCKS proxy to tunnel network connections through them, as it offers faster internet connections and is ideal for managing torrent traffic, despite the generic drawback of unencrypted traffic.

You can even access blocked sites in your country using a SOCKS proxy. There are many public SOCKS proxy servers available, but as mentioned earlier, traffic on a SOCKS proxy is not encrypted, so using a public one could be risky.

In this article, I’ll show you how to install and set up a SOCKS5 proxy server on Linux using MicroSocks.

MicroSocks: A Lightweight SOCKS5 Proxy Server

MicroSocks is a lightweight and multi-threaded SOCKS5 proxy server designed to robustly handle requests on servers with low resources by consuming minimal resources and gently denying new connections during heavy loads instead of aborting them.

It supports IPv4, IPv6, DNS, uses TCP (no UDP currently) for network proxy, and allows users to connect with or without a password or by providing a one-time password, all without needing to create or edit any configuration file.

Let’s now see how to install MicroSocks on popular Linux distributions like Debian, Ubuntu, Linux Mint, Red Hat, Fedora, Rocky Linux, Arch, or any others.

Install MicroSocks on Linux

MicroSocks is available in most Linux repositories, such as Debian, Ubuntu-based distributions, and Arch systems, where you can quickly install it using one of the appropriate commands based on your Linux distribution.

# On Debian, Ubuntu, Kali Linux, Linux Mint, Zorin OS, Pop!_OS, etc.
$ sudo apt install microsocks

# On Arch Linux, Manjaro, BlackArch, Garuda, etc.
$ sudo pacman -S microsocks

On Red Hat and Fedora-based distributions, or on older Debian and Ubuntu distributions, you can build and install it from the source, which also provides you with the latest version.

To start, ensure the development tools are installed on your Linux system, then run the following series of commands to install MicroSocks from source.

$ wget http://ftp.barfooze.de/pub/sabotage/tarballs/microsocks-1.0.4.tar.xz
$ tar -xvf microsocks-1.0.4.tar.xz && cd microsocks*/
$ make && sudo make install

Once the installation is complete, the MicroSocks executable file will be added to the β€œ/usr/local/bin” directory.

Start MicroSocks SOCKS5 Proxy Server

Now that the installation is complete, the β€œmicrosocks” command is available to use, but before that, let’s look at a few options you can use with it.

OptionDescription
β€œ-1β€œIt allows you to authenticate once, after which your IP address will be included in a whitelist, enabling you to connect to the proxy server later without authentication.
β€œ-qβ€œDisable logging.
β€œ-i ip-addressβ€œSpecify the IP address to listen on; not providing one means listening on all network interfaces in the server (default is β€œ0.0.0.0β€œ).
β€œ-p portβ€œSet the port to use for listening (default is β€œ1080β€œ).
β€œ-u user” and β€œ-P passwordβ€œSpecify the username and password for authentication in plain text, which can be anything regardless of existing users on the server.

In my case, I’ve set up the MicroSocks proxy server on a DigitalOcean VPS and started it using the following command, which listens on all server IPs with port 8484, the username β€œproxyuserβ€œ, and the password β€œsecurepasswordβ€œ.

$ microsocks -1 -p 8484 -u proxyuser -P securepassword

Output:

starting microsocks server

To connect to the above MicroSocks proxy server from the local machine, run the following command, replacing the green highlighted fields with the correct proxy server information.

$ curl --socks5 user:password@server-ip:port https://www.google.com/

Output:

connecting to microsocks proxy server

Once you do that, your local machine will be whitelisted for the MicroSocks proxy server due to the β€œ-1” option, allowing you to configure SOCKS5 with your browser or Linux system without providing credentials.

To connect to your MicroSocks proxy server from Firefox, navigate to β€œPreferencesβ€œ, then β€œGeneralβ€œ, scroll down to the β€œNetwork Settings” section, and click on β€œSettingsβ€œ.

firefox network settings

Then, ensure you enable manual proxy configuration, select SOCKS v5, and provide the host and port number of your SOCKS5 proxy server.

configuring SOCKS5 on firefox

Your Firefox is now configured with the MicroSocks proxy server, so all your browsing will go through the proxy server. If you encounter a connection failure error, make sure to re-execute the previous curl command.

To connect your local machine (running on GNOME) with the MicroSocks proxy server, first open β€œSettingsβ€œ, navigate to β€œNetworkβ€œ, and then β€œProxyβ€œ.

navigating to proxy section

Next, toggle the β€œNetwork Proxy” and choose the β€œManual” configuration.

enabling proxy configuration

Finally, enter the host and port of your MicroSocks proxy server in the β€œSOCKS5 HOST” section and save the changes.

configuring SOCKS5 on ubuntu

You now have your system running on GNOME, connected to your MicroSocks proxy server.

Allow MicroSocks Proxy Server Listening Port on Firewall

If you are running an Ubuntu system with UFW (Uncomplicated Firewall), you need to open the port your proxy server listens on. First, check the firewall status:

$ sudo ufw status

If it’s active and running, then open the port for the MicroSocks proxy server, which by default is 1080; however, since I’ve opted for a custom port of 8484 using the β€œ-p” option, I need to allow this port with the following command:

$ sudo ufw allow 8484/tcp

Output:

allowing firewall to microsocks proxy server

Create MicroSocks Proxy Server Systemd Service

To keep the MicroSocks proxy server running in the background and autostart on boot without any manual intervention, you can create a Systemd service.

To begin, open your terminal and create a Systemd service file using the command below.

$ sudo nano /etc/systemd/system/microsocks.service

Then copy-paste the following snippet.

πŸ“
If you’ve installed the MicroSocks proxy server from source, ensure to replace β€œ/usr/bin/microsocks” with β€œ/usr/local/bin/microsocksβ€œ. Additionally, you can add or remove the existing β€œ-u” and β€œ-P” options as needed.
[Unit]
Description=microsocks SOCKS5 server
Documentation=https://github.com/rofl0r/microsocks
After=network.target auditd.service

[Service]
EnvironmentFile=/etc/microsocks.conf
ExecStart=/usr/bin/microsocks -1 -u ${MICROSOCKS_LOGIN} -P ${MICROSOCKS_PASSW}

[Install]
WantedBy=multi-user.target

Save and close the file, then create a MicroSocks configuration file for the user and password variables used in the above Systemd service file.

$ sudo nano /etc/microsocks.conf

Copy and paste the following snippet, ensure to replace the user and password information with the correct MicroSocks proxy server details. Also, if you’ve customized the port or restricted IP in the Systemd service file, set their values accordingly in this configuration file.

# used by the systemd service file
MICROSOCKS_LOGIN="proxy-user"
MICROSOCKS_PASSW="proxy-password"

Save and close the file, then use the following command to enable and start the service:

$ sudo systemctl enable --now microsocks.service

To verify the status of the service, run the β€œsystemctl status microsocks” command.

checking MicroSocks service status

Uninstall MicroSocks from Linux

To uninstall the MicroSocks proxy server from your Linux system installed via the package manager, run:

# On Debian, Ubuntu, Kali Linux, Linux Mint, Zorin OS, Pop!_OS, etc.
$ sudo apt remove microsocks

# On Arch Linux, Manjaro, BlackArch, Garuda, etc.
$ sudo pacman -R microsocks

If you have installed it directly from the source, then run:

$ sudo rm /usr/local/bin/microsocks

To disable and remove the Systemd service, run:

$ sudo systemctl disable --now microsocks.service
$ sudo rm /etc/microsocks.conf

If you’ve allowed the MicroSocks listening port on UFW, then execute the following command to locate its index number:

$ sudo ufw status numbered

Then remove the corresponding port using the β€œsudo ufw delete [no]” command.

The post How to Setup SOCKS5 Proxy Server on Linux Using MicroSocks appeared first on Linux TLDR.

Reset the WordPress Admin Password Using CLI (via 2 Methods)

13 June 2024 at 18:56

WordPress is a popular CMS for bloggers and journalists, offering a range of features, including multi-user management, allowing admins to create separate accounts for different users with varying privileges.

The rule of thumb is to hand over the username and password to the user after account creation, but if the user or admin itself forgets the own password, the only option is to reset the user or admin password from the MySQL console or by using external tools.

In this article, I’ll show you how to reset (or change) the WordPress logins using the MySQL command-line client or the β€œwp-cli” command.

Method 1: Reset the WordPress Password via MySQL Command

The first step is to log in to your server running WordPress via SSH. Then, make sure to take a backup of your WordPress database. You can either create a snapshot of your server or use the backup option if you are using a hosting provider.

Alternatively, you can use the following command to export a specific MySQL database to an SQL file format by providing the MySQL username, password, and database name.

$ sudo mysqldump -u [user] -p [db_name] > [export_the_db.sql]

Once you have taken the backup, you can reset the WordPress password by first connecting to the MySQL or MariaDB server.

$ mysql -u [user] -p

Output:

connecting to mysql server

Then you need to select the WordPress database; if you forget the database name, you can use the β€œSHOW DATABASES;” SQL query to list all MySQL databases. Once you locate the correct database, use the following command to select it:

MySQL> use [wordpress_db]

Output:

selecting WordPress database

Then, for confirmation, you can run the following command to list all WordPress users:

MySQL> select user_login from wp_users;

Output:

listing wordpress username

I have only one user account named β€œlinuxtldrβ€œ, whose password I want to change. However, in your case, there could be one or more users, so note down the username and execute the following SQL query to update that user password (using the MD5 hashing algorithm):

πŸ“
Make sure all highlighted green fields are replaced with accurate information.
MySQL> UPDATE `wp_users` SET `user_pass` = MD5('changeme') WHERE `user_login` = 'wordpress-user';

Output:

updating wordpress user password in mysql command

When you are done, quit the MySQL console using the β€œexit” SQL query and return to WordPress to log in with the updated password.

Method 2: Reset the WordPress Password via WP-CLI Command

WP-CLI is a fantastic command-line tool for managing WordPress that you should definitely give a try. We’ve already covered its installation and command-line usage in a separate article, so we’ll skip those parts and focus on resetting the WordPress administrator password.

First, ensure you are connected to the system running WordPress, then open your terminal and navigate to the directory where the WordPress files are stored (typically, it’s β€œ/var/www/htmlβ€œ).

Then run the following command to list all the WordPress user accounts:

$ wp user list

Output:

listing wordpress users

Finally, select the username whose password you want to change, and pass it to the command below, along with the new password for resetting.

πŸ“
Make sure the green highlighted fields are replaced with the correct information.
$ wp user update wordpress-user --user_pass=changeme

Output:

changing wordpress login password using wp-cli

That’s it; you have successfully changed the WordPress password using the β€œwp-cli” tool.

Final Word

All the methods mentioned would work for resetting the WordPress password; you can choose one according to your preference. If you have any questions, feel free to ask them in the comments.

Till then, peace!

The post Reset the WordPress Admin Password Using CLI (via 2 Methods) appeared first on Linux TLDR.

❌