Trying to connect to a remote server using Eclipse - eclipse

I have an Ubuntu server running Tomcat, and I want to connect my Eclipse EE to it so I can work with JSP.
I have no problem connecting to a similar Tomcat service when it's installed on my machine (not a server), but whenever I try to connect to the remote server I don't seem to have the option of choosing a Tomcat service.
Is there some guide you can recommend (I didn't find one), or is there something I did wrong?

The "remote" Tomcat (or more generally the app server) must be configured to permit such connection.
Did you start the remote server with these parameters:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Alternatively you can add the word jpda at the end of the startup.sh (or .bat) script just when calling the catalina.sh script.
Everything is documented on the Apache Tomcat Wiki.
After enabling those options, you have also another task to do: enabling the network connection to the configured port (8000 in the above options). It depends which firewall is installed on the server but usually it is iptables.
Example of iptables command to enable connection to port 8000:
sudo iptables -A INPUT -p tcp --dport 8000 -j ACCEPT
If your server have a GUI installed, one easiest way is to use the "ufw" – short for 'uncomplicated firewall' as explained in this site which is just a graphical way to configure the iptables.
One way to test the connectivity to the server (if the port is open) is to use telnet from your computer like this:
telnet your.distant.host 8000
and if the command opens, the port is accessible, if the telnet command times out, the port is closed.

Related

How to access Mongodb in AWS EC2 Ubuntu from my laptop [duplicate]

I've successfully installed MongoDB on Windows (on a local machine) as a service, but now I want to move MongoDb to a separate server. So I extracted the tarball to a virtual server on network (running linux).
When I connected to the server ("testmongoserver") using PuTTY from my local machine, I started the mongod server and it told me that it was listening to the default 28017 port. The mongo console is also working and allowed me to create a new database (testdb) and add users to it.
However, I could not access the server from remote. When I type testmongoserver:28017 it doesn't open the HTTP console as localhost:28017 on my local machine does. I also can't connect using official drivers and providing a connectionstring.
What are the neccesarry steps to install MongoDB on Linux, so that I could access it from a remote machine with a connectionstring and use its HTTP console via testmongoserver:28017
Thanks!
1. Bind IP option
Bind IP is a MongoDB option that restricts connections to specifics IPs.
Have a look at your mongod configuration file, most of the time bind_ip is set to 127.0.0.1 for obvious security reasons. You can:
Add your desired IP by concatenating a list of comma separated values to bind MongoDB to multiple IP addresses.
Remove or comment (with # character) the bind_ip line. But be aware that all remote connection will be able to connect your MongoDB server!
More about bind_ip configuration option: https://docs.mongodb.com/manual/reference/configuration-options/#net.bindIp
Bind IP can also be set as a command argument: http://docs.mongodb.org/manual/reference/program/mongod/#cmdoption--bind_ip
2. Firewall
Check that you are not running behind a firewall
Make sure in your /etc/mongodb.conf file you have the following line,
bind_ip = 0.0.0.0
http://jitu-blog.blogspot.com.br/2013/06/allow-mongo-to-connect-from-remote-ip.html
Run netstat -a on mongo server and check a port.
Check DNS settings and check that linux server allows external connections.
Check that mongodb can accept external/remote connection.
Default port for mongo is 27017.
28017 - port for webstats.
See http://www.mongodb.org/display/DOCS/Security+and+Authentication#SecurityandAuthentication-Ports
Just had this issue and this fixed it:
Edit /etc/mongod.conf with sudo nano /etc/mongod.conf ensure that the net section looks like below (localhost binding by default doesn't allow for remote access):
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
Make sure to restart mongod when you are done with above with below (assuming systemd ubuntu 16.04+ etc.):
sudo service mongod restart
Obviously from a security perspective if you are going to be opening up mongo to your network/the world be aware of the implications of this (if any)
Another problem may be that the mongodb port is not enabled. Check, from another host, the ports enabled on your server. For that you can use the command:
sudo nmap -P0 your_server_ip
You can get an answer like this:
Host is up (0.052s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp closed https
If you use a virtual server in the cloud, as AWS, you need to add a new rule to add mongodb port (27017 by default).
Important: Note that with this configuration anyone can have access to your database
I fixed by below reference :
https://medium.com/founding-ithaka/setting-up-and-connecting-to-a-remote-mongodb-database-5df754a4da89
Actually, first i changed my bindIp from 127.0.0.1 to 0.0.0.0 in mongod.conf,
and enable security:
security:
authorization: "enabled"
then i restarted mongod using sudo service mongod restart.(because of new changes in mongod.conf), after that set firewall to open mongod running port (by iptables) and create a new user in admin db with new access (based on this link : https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac), finally test open ports in my server from outside with (https://www.yougetsignal.com/tools/open-ports/) and connected successfully to remote mongod using mongocompass.exe.

Connecting Xdebug with NetBeans and Vagrant

I have spent quite a bit of time on this with no success. I am trying to connect my Xdebug through NetBeans to my Vagrant server.
The IP address of the Vagrant box is 192.168.33.10.
When NetBeans opens the debugging connection it says that it's looking at 192.168.33.1.
My php.ini settings are as follows
zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.profiler_enable=1
xdebug.profiler_output_name="cachegrind.out.%t.%p"
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.remote_enable=1
xdebug.remote_log = /tmp/xdebug.log
xdebug.remote_port = 9000
xdebug.remote_host=192.168.33.1
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=0
xdebug.idekey="vagrant"
xdebug.remote_mode=req
;xdebug.remote_connect_back=1
In NetBeans my project URL is set to http://192.168.33.1:9000
debugger port is 9000 and Session ID is vagrant.
I know that NetBeans also looks at IP address 10.0.2.2 and I can't get this going either. When I run the debugger NetBeans just says that it's waiting for connection and my log stats that the connection has timed out.
I have also tried it with remote_connect_back=1 and to no avail.
Thank LazyOne for your feedback much appreciated
What I had to do to get this going was to open the ports 9000 on my windows machine and port 9000 on my server. I then login to my ssh server connecting to 127.0.0.1:2222 as specified by the vagrant bootup messages. Then set up a ssh tunnel to connect to port 9000. I did this using putty

MongoDB Server Ubuntu 16.04

I've installed MongoDB on my Ubuntu 16.04 VPS and allowed connections through the firewall. When I run the server using the command (mongod), it starts without a problem and I can then connect to it (using RoboMongo as test application).
However, when I run the service automatically on startup (using systemctl), I cannot connect to it. I verified it was running, and could not run it myself as the address was already in use.
Does anyone have any experience with this, or any tips on how to solve the problem? The server will be running localhost only and I'm going to be using an SSH tunnel for testing purposes, so no authentication is necessary.
Anyone?
When you started mongod did you then provide a configuration file (using the --config or -f parameter)? If not then it defaults to listening on all interfaces.
The default configuration file which is used when starting the daemon with systemctl defaults to only listen on localhost preventing it from being available on the network. This is fine if you intend to connect to the server using a tunnel.

Remote debugging tomcat with OpenShift

I am using openshift for my tomcat webapp. I am able to run the app but unable to debug it. As openshift starts tomcat in debug mode, I was expecting I'll be able to debug.
Host:
$OPENSHIFT_JBOSSEWS_IP
Value of this is 127.5.20.129 for me which I got from command:
rhc port-forward -a {appname}
Port:
$OPENSHIFT_JBOSSEWS_HTTP_PORT
Value is 8080 for me.
I tried above host/port. I tried port 8000 too but nothing works. I am unable to connect from eclipse remote debugger each time.
Please help.
You should read through the Developer Portal's pages on Port Forwarding (https://developers.openshift.com/en/managing-port-forwarding.html) to make sure that you are using it correctly. You will want to connect to your local loopback address: 127.0.0.1 along with the correct forwarded port once you have run the port-forwarding command.

mongodb client - ssh connection from localhost php

I have been using rockmongo as my client for mongodb on localhost for testing.
For prodction i DONT want a client online as this might reduce security.
Is there a client which will allow me to connect SSH? kind of like MySql Workbench?
or
Can rockmongo stay on my local computer and i connect to EC2 instance which has mongodb for production viewing?
or
Is there a better alternative to all of this?
My setup is a standard LAMP stack. willing to make any changes necessary.
MongoHub has the option to connect over ssh, but the app kind of sucks. It crashes a lot.
A more generic approach would be to just create your own ssh tunnel to your production server, and then connect over that through whatever client you want. The client won't care as long as it can make the connection.
On OSX/Linux, creating an ssh tunnel might look like this:
ssh -L 8080:127.0.0.1:27017 -f -C -q -N username#domain.com
This would open a local port 8080 which will forward the traffic to the localhost interface at the mongodb default port 27017 on the remote side. You would point your client at 127.0.0.1:8080 as if mongodb were running there locally.
Check some of these out - http://www.mongodb.org/display/DOCS/Admin+UIs
One workaround would be to set that file in a separate folder and make a .htaccess file that restricts access to only your ip address. Any requests not from your ip address would get denied access...