I need to make backups of the remote machine mariadb database. My plan is to run
ssh user@remoteip 'mariadb-dump -uuser -ppass --all-databases > backup.sql'
from my local machine.
I found that remote machines history
is not being populated with the mariadb-dump command I just executed. journalctl
also did not contain the command.
Is there any security reason on the remote side I should be worried about when passing mariadb password in the ssh command? Are there better alternatives?
Yes this is very unsecure.
While running, any user on the system can see the plaintext password with
ps aux
.You should rather add a file
~/.my.cnf
for the user with permissions 600 and following content:Since the MariaDB and system users seem to match, you could also allow the system user
user
to authenticate as the MariaDB useruser
throughunix_socket
:This will grant passwordless login as the MariaDB user named
user
to the system user nameduser
(which may be convenient in general), leaving to other system users the option to authenticate as the MariaDB user nameduser
using the passwordpass
(you may run justALTER USER 'user'@'localhost' IDENTIFIED VIA unix_socket;
if the latter is undesirable).Then you could run just: