Redis, an in-memory data structure store, is highly valued for its speed and simplicity, and is commonly used as a cache, database, or message broker. When working with Redis on a remote server, connecting without SSH can be essential in environments where SSH access is restricted or simply not practical. This guide will explore how to securely connect to Redis remotely without using SSH, detailing necessary configuration steps, security best practices, and popular tools that make the process smooth and secure.
By default, Redis only listens on the local address (127.0.0.1) and port 6379 to enhance security. To enable remote connections, you’ll need to configure Redis to listen on all network interfaces or a specific IP address.
Connect to Redis server and check the status
sudo systemctl status redis
The above command will give you the status
Modify the Redis Configuration File (redis.conf):
sudo nano /etc/redis/redis.conf
change the bind directive from 127.0.0.1 to 0.0.0.0 or based the application IP this can be changed
Set a Strong Password:
requirepass <YourSecurePasswordHere>
Update the protected-mode Setting:
protected-mode no
Step 2: Use Firewall Rules for Security
To prevent unauthorized access, configure firewall rules to restrict which IP addresses can connect to your Redis instance:
Configure UFW (for Ubuntu):
sudo ufw allow from <allowed-ip-address> to any port 6379
Use iptables (if UFW isn’t available):
sudo iptables -A INPUT -p tcp -s <allowed-ip-address> –dport 6379 -j ACCEPT
sudo iptables -A INPUT -p tcp –dport 6379 -j DROP
Once Redis is configured for remote access, you can connect to it using popular Redis clients. Below are a few tools commonly used to connect to Redis:
Command-Line Interface (CLI):
redis-cli -h <redis-server-ip> -a YourSecurePasswordHere
Post all these changes some setups will have firewall blocked for other ports, since redis runs on only 6379 default port, we can open firewall port to enable smooth connections
Conclusion
Connecting to Redis remotely without SSH can be done securely by configuring Redis, setting up firewalls, and enabling TLS if encryption is required. By following these steps, you can ensure that your Redis instance remains secure, accessible, and performs reliably across different environments. This approach also makes Redis an excellent choice for scalable applications without compromising on security.
Happy Reading!!!..
Lochan R