I was recently building a script to help move things from one server to another and in the process stumbled into a very annoying problem when passing MySQL arguments to a remote server via SSH.
Desired outcome: Create a new user in a remote DB using SSH.
In practice, this should be extremely simple. If you do this on the server, you could execute a command like this:
mysql --user="root" --password="[pass]" --execute="create user 'testing'@'localhost' identified by '123';"
You would now have a new user in your database called testing and it’s password would be 123.
This post assumes you have successfully installed PHP-FPM and have confirmed it is running on the server, and
# systemctl status php7.2-fpm.service
● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-08-13 03:40:43 UTC; 14min ago
Configured on the site:
But still getting this:
The good news is you are actually pretty close, and it’s actually something you missed in your site config file.
Go back and verify the port you’re listening on (e.g., vim /etc/php/7.2/fpm/pool.d/[pool name].conf). For instance, in my case it was:
DD-WRT is an OpenSource router firmware supported by most modern router systems. If you want to open the door to what you can do with your router, DD-WRT is the way to do it. It allows you to bypass the limitations your commercial router software introduces.
Ok, let’s cut to the chase..
Permission Denied Using SSH with DD-WRT
If you’re like me, you have probably hit a brick wall when trying to SSH into the router after it’s been imaged with DD-WRT.
Check All SSH Settings
There are two place you want to update SSHD settings. Navigate to the following location
Services > Services > Secure Shell
Here, you will enable the SSHD daemon.
Make note of the port you’re using, and select to use a password or key or both. This is pretty straight forward, in my scenario I selected to disable password login and use my public SSH key for security.
Then, navigate here:
Administration > Management > Remote Access
Don’t ask me why, but here you will make sure that SSH Management is Enabled and that your port is set the same as the last page.
Now save, and reboot the machine to make sure the changes stick.
Verify Username is Correct
If you are still having an issue, and it looks something like this:
$ ssh admin@192.168.1.1
DD-WRT v3.0-r44048 std (c) 2020 NewMedia-NET GmbH
Release: 08/02/20
Board: Linksys WRT3200ACM
admin@192.168.1.1: Permission denied (publickey).
or, something like this:
$ ssh admin@192.168.1.1
ssh: connect to host 192.168.1.1 port 22: Network is unreachable
tony:public antonioperez$ ssh admin@192.168.1.1
DD-WRT v3.0-r44048 std (c) 2020 NewMedia-NET GmbH
Release: 08/02/20
Board: Linksys WRT3200ACM
admin@192.168.1.1’s password:
Permission denied, please try again.
admin@192.168.1.1’s password:
Permission denied, please try again.
admin@192.168.1.1’s password:
But you swear you are using the same username and password you log into the GUI with, then it might be something a little more frustrating.
The user.
Update the user to root instead of whatever user you were using. In my case, I was testing with admin.
After updating the username to ROOT:
$ ssh root@192.168.1.1
DD-WRT v3.0-r44048 std (c) 2020 NewMedia-NET GmbH
Release: 08/02/20
Board: Linksys WRT3200ACM
Enter passphrase for key ‘/Users/antonioperez/.ssh/id_rsa’:
Tada! Like magic, it started working. I have no idea why this is, but I have successfully used this on three DD-WRT installations and it works every time.