I have the following instruction and it works.
ssh -i /e/Data/openssh.ppk firstname.lastname@example.org ssh cos-server "pwd "
But when I execute the instruction below:
ssh -i /e/Data/openssh.ppk email@example.com ssh cos-server "mysql -u bduser --host=tdb --password=pass -e \"SELECT 1 AS Quantity;\""
It asks for my passphrase. I entered it but the command appears to fail and the output shows mysql options. I don't know if another quotation mark is required.
This is the output:
Warning: Permanently added 'cos-server_avm,100.69.35.5' (ECDSA) to the list of known hosts. mysql Ver 15.1 Distrib 10.2.13-MariaDB, for Linux (x86_64) using readline 5.1 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Usage: mysql [OPTIONS] [database] Default options are read from the following files in the given order: /etc/my.cnf ~/.my.cnf The following groups are read: mysql client client-server client-mariadb The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file. --defaults-file=# Only read default options from the given file #. --defaults-extra-file=# Read this file after the global files are read. -?, --help Display this help and exit. -I, --help Synonym for -? --abort-source-on-error Abort 'source filename' operations in case of errors --auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash. (Defaults to on; use --skip-auto-rehash to disable.) -A, --no-auto-rehash ... ...
ssh -i /e/Data/openssh.ppk firstname.lastname@example.org ssh cos-server 'mysql --user=bduser --host=tdb --password=pass -e "SELECT VERSION();SELECT NOW()"'
Warning: Permanently added 'cos-server,100.69.35.5' (ECDSA) to the list of known hosts. bash: -c: line 0: syntax error near unexpected token `(' bash: -c: line 0: `mysql -u bduser --host=tdb --password=pass -e SELECT VERSION();SELECT NOW();'
What is missing in this case?