My application use database which is on another server. To increase security, access to db server was restricted only for specified production servers.
However sometimes I need to have access to this db, when running development environment from my localhost.
For now a simply run in another console before running server:
ssh tunnel#server-with-access-to-db.com -L 12345:localhost:3306
..which works great, however I need to remember to do that.
I am wondering how to write custom runserver which will establish tunnel automatically, and what is important, will close that tunnel after server will be shut down.
I know that in the future VPN will be much better, however it is not possible for now.
I will be grateful for any suggestions.
FYI: one part of writing custom runserver command is extending it. You can use this example to do so.
Related
I'm trying to run my application on GCE VM. It uses nodeJs as frontend and a Java backend. I use this server to communicate with my local computer using MQTT. This is working but after some time (one hour and a half), the server seems to go to sleep (or the ports close ?).
Both MQTT and ssh terminal interface connections are lost.
When I connect back, the application is not running anymore, it seems like the VM restarted.
Do you have any idea on how to keep my server alive ? I can give further details.
Answering my own question as John Hanley explained the solution in comments:
"By what method are you running your frontend and backend code. VMs do not go to sleep. If you are starting your software via an SSH session, that will be an issue. Your code needs to run as a service. Edit your question with more details."
I was indeed running my application via the ssh terminal which caused the problem. The solution for me was to remotely access the VM via vncserver and to launch the application using the VM's terminal.
I inherited management of some Promise VTrak disk array servers. They recently had to be transferred to a different location. We've got them set up and networking is all configured, and even have a linux server mounting to it. Before they were transferred I was trained with the web gui it comes with. However, since the move we have not been able to connect to the web gui interface.
I can ssh into the system and really do everything from there, but I would love to figure out why webserver is not coming up.
The VTRAK system does not allow for much configuration it seams. From the CLI I can start, stop, or restart the webserver, and the only thing I can configure is the amount of time someone can be logged into the gui for. I don't see anywhere where you can configure http or anything like that.
We're pretty sure it's not a firewall issue as well.
I got the same issue this morning, and resolved it as follows:
It appears there are conditions that can render the WebPam webserver with invalid configuration HttpPort and HttpsPort values. One condition that causes this is if the sessiontimeout parameter exceeds 1439 set in the GUI. Apparently the software then freaks and creates invalid configuration which locks out the GUI because the http ports have been changed to 25943 and 29538.
To fix this login through CLI:
swmgt -a mod -n webserver -s "sessiontimeout=29"
swmgt -a mod -n webserver -s "HttpPort=80"
swmgt -a mod -n webserver -s "HttpsPort=443"
swmgt -a restart -n Webserver
You should now be able to access the WebPam webserver interface again through your web browser.
After discussing with my IT department we found it was a firewall issue.
I'm unfamiliar with this terrain, so if any one can guide me in a step by step manner- it would really help. My MySQL database sits on a AWS host X- "ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com". It is blocked to access from individual local machines and is usually accessed from another working server Y- "ec2-yy-yyy-yyy-yy.compute-1.amazonaws.com" through port '3306'. Now it is especially inconvenient to access this via terminal SSH every time and scripts while they run, its hard to prototype or build an elaborate app. I'd like to set up a SSH tunnel from my local to server Y to be able to access MySQL host X from my local machine, to run queries from my locally deployed Jupyter notebook as well as local working-in-progress Django web app.
The reason why I ask for something more step-by-step is that I have to port forward to another server hosting a redis database which again is accessible through a specific server only. So, I'll be able to carry the solution from here to there too. I'm willing to go into chat as well if needed, but I need to resolve this rather quickly. Thanks!
PS: I've tried many guides off of the internet, but nothing has worked, it's become clear to me that I'm missing some foundational understanding or pathway. That's why I'm here, trying to start from the ground.
I am using Gunicorn to power Django application on a remote server (ubuntu), to which I connect by ssh. Once Gunicorn has started the status log pops up showing you what is going on and such. However when I close my ssh session and reconnect later on I cant seem to reopen the process without killing Gunicorn and rebooting the server.
Not sure if i understand your issue correctly...
When running django/gunicorn usually it is helpful to use some tools to control the processes. One really good option to do so is the use of supervisord:
http://docs.gunicorn.org/en/latest/deploy.html#supervisor
If you just want to run processes directly and being able to (dis-)connect - generally screen is a good option.
It allows you to to disconnect an ssh-session while leaving your 'virtual?' terminals running.
Just re-ssh to your server and reconnect using:
screen -xr
Either this this question isn't asked often (possible), everyone knows how to do it (doubtful), or I don't know how to search for it (likely).
I want to get my C++ program talking to my MySQL server and able to run commands on it. I know MySQL has connector code available, but 1) it seems like much more than I need and 2) I just cannot seem to get it to work anyway.
I want to be able to test the program on my computer, so remote access would be necessary. I do have SSH for the server.
My final deployment will be able to run on the server itself.
Executing and receiving/parsing output from MySQL databases is quite easy to do by hand. I can't however, figure out which way to go to get my program to do this.
I figure I should be able to:
1. ssh into the web server (with password)
2. access the MySQL database
3. execute statements and retrieve their output
I've read a lot about fork() and popen(), but due to their read-only or write-only limitations (unless I misunderstand), I just don't know where to go. Obviously I'd just take out the SSH step when the time comes to deploy it on the server. Can somebody give me some direction on this, or is this just not possible (doubtful).
It is our own dedicated server so we have full reign with ssh and WHM, but I'd rather minimize the "intrusion" since I don't know enough about all the software on there if I broke something. I just want to communicate [directly] with the MySQL database.
Thanks so much! You guys are awesome!
If you have SSH access, then you're way overcomplicating this.
Step 1: Set up an SSH tunnel:
ssh -L 3306:localhost:3306 user#your.host.com
Step 2: Use the local port like normal (i.e. just refer to localhost)
mysql -u root -p < somescript.sql
However since you're using C++, you really should use a proper library (e.g. MySQL++). Educate yourself on SSH tunnels, they make life so much easier once you know about them.