Forums

autossh to connect to database

I am trying to connect chartio to a mysql database on pythonanywhere. The instructions state that you should install autossh to make sure that the ssh connection is reinstated on reboot.

From what I can tell, we can't normally install anything using apt-get. Are there any workaround for this?

Hi there,

if you can figure out how to install autossh without needing root privileges, then that could work (maybe compile from source?)

alternatively, you could use our scheduled task hack to do an auto-restarting "always-on" task to run your ssh tunnel: http://help.pythonanywhere.com/pages/LongRunningTasks

Thanks for the tip. Compiling by source worked.

But now I have a second issue....

Chartio's ssh login system asks for a database username and password as well as an ssh key. I have the key setup and verified. Here is what the system asks for.

Chartio SSH Setup

This pythonanywhere link doesn't have instructions for using a key. But I got it setup and connecting to the server except my credentials are not being accepted. I tried using both my database password and my pythonanywhere password.

In the instructions that you linked to, you created a ~/.ssh/id_rsa ssh key pair (private and public).

It's unclear to me whether you need that keypair on PythonAnywhere vs on your location machine vs on Chartio etc. If you have the private key on your local machine and you are trying to use it to ssh into PythonAnywhere, then you should have the public key in your PythonAnywhere account's authorized_keys file.

I think i figured out the issue. Chartio requires a read only user for mysql. We can't create new users in mysql so I will either need to upgrade to postgres or use and external mysql db.