How to access Apache Mina sshd sftp server from remote machine - java

I start up sftp server using Apache Mina Sshd Api. please refer follow link to see more details about my local SFTP server.Link.
I tried to connect to that server from remotely by giving host name as my ip address but i couldn't enable to connect with the sftp server. I got "connection refused" error message.But i can connect locally.To connect locally i use winscp sftp client giving my host name as "localhost" but in remotely i can not give host name as localhost.So i gave host name as my machine IP address.When i gave that i got above error message.
So i would like to know that how can i connect with my local sftp server from remote machine.
Thank you.

Hi finally found out How to access Apache Mina sshd sftp server from remote machine. The problem was on my Apache Mina sshd sftp server set up.You can refer attached link to see my Apache Mina sshd sftp server details.
In there previously i set host as sshd.setHost("localhost"); instead of that i changed it into sshd.setHost(0.0.0.0);.So now you can access your local sftp server providing your machine ip address as a host name from remote machine.

Related

Java Connection to MySQL-Database over HTTP or HTTPS

I'm working on a little java project and I have a problem.
The Mysql-Protocol is blocked by the Firewall and the only ports I'm able to use are 80 or 443. Is there any way to connect to my database over these ports? Acutally I'm using the mysql-connector library for java to connect.
You can change the port of MySQL.
change the port in /etc/mysql/my.cnf
example :
cp /etc/mysql/my.cnf /etc/mysql/my-3307.cnf
//edit my-3307.cnf, for example
port = 3307
basedir = /var/lib/mysql-3307
datadir = /var/lib/mysql-3307
//end-edit
mysql_upgrade --defaults-file=/etc/mysql/my-3307.cnf #checks the syntax and creates the dirs you need.
#start mysqld
mysqld --defaults-file=/etc/mysql/my-3307.cnf
source : http://dev.mysql.com/doc/refman/5.1/en/multiple-servers.html
PS : 443 is default https port. It is not advisable to use this and 80(http) port.
Maybe you can change the MySQL port to 443;
But, i think it's bad...
I recommend you to setup SSH server on 443 port and use it for tunelling traffic to your database and any other service.
Here's how you can tunnel traffic from your local machine to remote database:
ssh -L 9000:localhost:3307 user#1.2.3.4 -p 443
Now you can connect to database, like you have it running locally on localhost:9000. All your traffic to SSH server is encrypted. Check this article for another examples.
You can also check chisel project, however I'm not very familiar with it.

Remote debugging from eclipse

I am trying to remote a debug an application which is deployed through Websphere. I have all the port configured correctly on server side and on eclipse side. I can use
telnet host port
to connect to remote host and port correctly. But When I try to connect through remote debug through eclipse, I run into the error
Failed to connect to remote VM
com.sun.jdi.connect.spi.ClosedConnectionException
What can be the possible causes for this? I have checked and searched Stackoverflow for this error already. I have tried the most things from answer on this question Eclipse Error: "Failed to connect to remote VM"
I changed the port and it worked. It was a networking issue with that port of 7777.

connect amazon mysql with JDBC through remote server

I had a problem here, is it possible that JDBC connecting to the amazon MySQL server remotely? I searching on the Internet for solution but ended up receiving the error
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
I am using jsch.jar to connect the remote server, then call up JDBC connector trying to connect MySQL DB, I had successfully connected to the remote server yet I cannot connect MySQL DB on amazon, here is my code
testPutty t = new testPutty();
t.connect("admin", "", "xx:xx:xx:xx", "openSSHPrivateKey", 22);
t.connect();
System.out.println("connected");
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection("jdbc:mysql://staging.ppyhcsxnlkji.ap-southwest-1.rds.amazonaws.com:3306/staging","superuser","password");
System.out.println("hello world");
t.close();
First set up the tunnel with SSH. You haven't shown what testPutty is so I'll assume it's a thin Java wrapper around a command line invocation of Putty. The command line option for setting up a tunnel is
-L[localport]:[host]:[remoteport]
For your example this would be
-L3306:staging.ppyhcsxnlkji.ap-southwest-1.rds.amazonaws.com:3306
This sets up a tunnel that forwards connections to local port 3306 to port 3306 on the given host (staging...amazonaws.com) on port 3306, routed through the host that is the target of the SSH command (in your sample xx:xx:xx:xx).
Then, your connection string needs to use localhost instead of the actual remote:
jdbc:mysql://localhost:3306/staging
If 3306 on your local host is not available because you are also running a local copy of MySQL, just choose a different unused port.

Error while connecting remote connection SFTP in Netbenas

While I am trying to connect my project to remote server in NetBeans.
Please help me to resolve this error in SFTP connection.
Can't connect to server 31.XXX.XX.XX
Cause.Session.connect:Java.net.SocketTimeoutException:Read timed out
Try to telnet to IP:PORT and check whether it is working.

Could not connect to glassfish ip address on windows server 2008

I have developed a servlet and deployed it on my server -windows server 2008-
the server have an ip and the port of the glassfish 3.1.2 server is 11188, when i call the servlet from the local host it works fine, but when i call the server via the ip address this error shown could not connect to NN.NN.NNN.NNN:11188 ;N: is a number.
How do i solve this issue?
Open the port 11188 in the firewall.
I was forget to define the port 11188 on the approved ports on the hoster control panel

Categories