Node.js: Hooking repl to a remote node server - security

Let's say I have a node server running at mysite.com. Is there a way to set up that server so that I can use node's repl api to securely connect to it from my local machine?

Well, if you used this example:
net.createServer(function (socket) {
repl.start("node via TCP socket> ", socket);
}).listen(5001, "localhost");
And firewalled that port 5001, you should be able to securely connect to it using ssh:
ssh user#host nc localhost 5001
In this case, the security relies on your firewall, and ssh.

Related

How to connect to a rethink db hosted on centos?

I have my rethink db hosted in centos and proxied port 8080 to a domain name using nginx.
From my local pc, how do I connect my app to the server?
you need to open 28015 port on your centos server, than you can connect to rethinkdb listening on 28015 port of your centos server via this connection string
r = require('rethinkdb')
r.connect({ host: 'centos.example.org', port: 28015 }, function(err, conn) {...});
where centos.example.org is hostname/ip of your server.
its worth notice that you should either whitelist your IP in firewall (so, only connections from your home IP is allowed), or install authorization and tls certs on rethinkdb server.
this documents can help -
https://rethinkdb.com/docs/install/centos/
https://rethinkdb.com/docs/start-a-server/

Connect to external server over ssh

I want to connect to local address 127.0.0.1:2222 belonging to a server with IP 172.25.250.10 as user especial. The connection would be done from another place in the network. As a tip they have told me to use ip forwarding but I cannot manage to succeed.
My approach has been doing:
ssh especial#172.25.250.10 -p 2222
But this attempt returns:
ssh: connect to host 175.25.250.10 port 2222: Connection refused
In the 172.25.250.10 the 2222 port is listening for ssh connections
If I understood correctly, use the following to connect to 172.25.250.10 and use local port forwarding for port 2222.
ssh -L 2222:localhost:2222 especial#172.25.250.10

SSH tunnel always trying port 22

I want create ssh tunnel between local machine and remote server, so I use this command on my local machine:
sudo ssh -R 443:localhost:443 SERVER_IP
Everything is working, I can connect to my local machine through remote server - using port 443.
Problem is, that sometimes it just doesnt work and I get a message:
connect to host SERVER_IP port 22: Connection refused
Strange is, that connection to port 22 is working on remote (I can connect there without problem at that exact moment), weird is just, that sometimes it is working and sometimes id does not. Do you have any idea why? Or do you know what is going on?
ssh runs by default on port 22. While your command is setting up a proxy to pass port 443 from one host to port 443 on a different host, the underlying ssh connection still runs on port 22.
Connection refused means that the target host SERVER_IP is not running an sshd daemon and/or is not listening to port 22. You will need to figure out and fix whatever is wrong with the SERVER_IP machine.
22 is the default port, the ssh client will connect to it until you specify an other port using -p, example:
ssh -R 12345:localhost:12345 SERVER_IP -p 443
The error you have is not about the tunnel but about the server's port.
You should check that the server is indeed started and listening on port 22 and there's no firewall in the way.

Accessing application in browser over SSH proxy on localhost.

I have SSH access to a web server that is hosting an application on port 8080. I have a SSH session setup and a proxy configured on Chrome to redirect requests to SSH tunnel. I basically configured it using these instructions: http://drewsymo.com/2013/11/ssh-tunnel-in-30-seconds-mac-osx-linux/
I can confirm using Whats My IP that my IP is that of the SSH session and that is working correctly.
But I cannot figure out how to access the local application on the web server that I am SSHed into. When I try localhost:8080 the SSH session gives me an error "channel X: open failed: connect failed: Connection refused"
Any idea what is going on?
You can just create a port-specific tunnel:
ssh -L18080:localhost:8080 username#theothermachine
and then go to localhost:18080 on your local machine. The tunnel will forward your request to port 8080 of the localhost on the other end (and of course, localhost on the other end is the other machine itself). If that doesn't work for some reason, then replace localhost by 127.0.0.1 in the ssh command.

Sequelize connection over ssh

I am not able to connect to a remote mysql server using sequelize but I am able to ssh into the machine and connect to mysql.
How do I make Sequelize connect to mysql server over ssh rather than directly in node?
You set up an SSH tunnel to your server, which listens on (for example) port 33060:
ssh -NL 33060:localhost:3306 yourserver
In another window/terminal, you can use the MySQL client (assuming that it's installed locally) to connect to the remote MySQL server over the SSH tunnel:
mysql --port 33060 --host 127.0.0.1
If that works, it's just a matter of changing the port number in Sequelize:
var sequelize = new Sequelize('database', 'username', 'password', {
host: "127.0.0.1",
port: 33060
});
If it doesn't work, it might be that the remote MySQL server isn't configured to accept connections over TCP. If that's the case, you should configure your MySQL server to get it to accept TCP connections.

Resources