I have been trying to solve this for a couple of days and don't seem to find a way to do it. I have a raspberry pi in my local network which is running jupyter (port 8888) and a flask api (port 5000). I want to be able to access it remotely using another server. My setup and what I have until now is:
Server in GCP with static IP (let's say it's gcp.static.ip). I opened the ports 7003 and 7004 as udp.
Raspberry Pi in my home network with dynamic IP (can't have static IP) and jupyter and flask api on ports 8888 and 5000. I forwarded the ports with:
ssh -NR 7003:localhost:5000 -R 7004:localhost:88888 user#gcp.static.ip
Laptop in remote network. If I do the following ssh tunnel I can access the jupyter server at localhost:7004:
ssh -NL 7004:localhost:7004 user#gcp.static.ip
I can't seem to do the same for the flask API. If I ssh into the gcp server I can query the API at port 7003. How can I set the gcp server so that I can query the api with gcp.static.ip:APIPort and access jupyter in gcp.static.ip:JupyterPort.
Thanks a lot!
UPDATE: I'm able to query the api forwarding a TCP port. However, still want to know if this is possible without having to create another tunnel on my lapto.
Following this Link. Had to change /etc/ssh/sshd_config to set GatewayPorts to clientspecified and ssh tunnel with:
ssh -NR 0.0.0.0:7003:localhost:5000 user#gcp.static.ip
Related
I'm trying out the command python http.server from the command line, and am trying to access the server. I can access easily from localhost, but whenever I try to use a remote connection, I am unable to connect.
I've tried different ports, and it doesn't look like my firewall is blocking any connections.
From the command line, I run
python3 -m http.server 8000
which returns
Serving HTTP on 0.0.0.0 port 8000 ...
However, I can only connect to the server from localhost.
sudo iptables -S
returns the following:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
I expect to be able to connect from a remote host with the url http://10.247.30.125:8000 (my ip address), but I am unable to do so. The same url works fine on localhost.
I figured out what was going on. Did some reading about IP and NAT, and noticed that any ip address beginning with a 10 is reserved for private ip addresses. So, trying to connect to 10.247.30.125:8000 from anywhere other than my own network (so while not connected to my wifi) doesn't work. To be able to connect from an external network, I would need to set up port forwarding (like Reedinationer suggested), and I would need to use my router's public IP address rather than my computer's private IP address. I would set up a port forward from my router to direct external traffic to my computer, which would allow me to connect to my personal computer from an external network.
Thanks to everyone who responded!
port is missing from the url try this url it should work "http://10.247.30.125:8000"
I installed a web server on a remote machine that can be only access through a ssh tunnel. Therefore, I have run with putty a ssh tunnel by specifying a port forwarding (in my case 8159). I have also configured the socks proxy on my browser to access to my remote webserver. Futhermore, with a curl command I can get the webpages if I add the following option --sock5-hostname localhost:8159.
Now, I would like to use python to request those webpages by passing through the ssh tunnel that I have configured with putty. I tried pysocks and proxy environment variables in my python code but it did not work. I would like to know if you have an idea to solve this problem.
Thank you in advance.
I'm trying to setup a remote Jupyter Notebook server on an AWS Ubuntu machine.
I followed this blog: http://blog.impiyush.me/2015/02/running-ipython-notebook-server-on-aws.html
I'm able to do a wget on the server and get the html. However when I try from my laptop browser i get a Connection Timed Out message.
I thought it may be a port issue for port 8888 (on which my notebook server is configured.
So I did sudo ufw allow 8888. Doing netstat shows that python is listening to all IPs on the port:
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 1833/python
Posting here for future reference.
Found the issue. The AWS Security Group settings were not configured to allow incoming connections on either HTTPS (443) or 8888. I added those rules in to the AWS console and it started working.
Go to Inbound settings, change rules, below rules worked for me !
I'm having a unique problem with Windows Azure that I don't see on other providers. I've been running connections from remote VMs to a MySQL database running on a DigitalOcean VM. I've successfully connected with AWS, Rackspace, Google, and all other providers, but for some reason, Microsoft Azure VMs don't seem to work.
VM OS: Ubuntu 14.04
I'm trying to connect using PyMySQL and SQLAlchemy.
What I've Tried:
The port is open and listening
The user definitely has permission to upload data into the DB (other remote connections with this user all work fine).
I have even tried "ufw disable" for the Firewall on the Windows Azure VM
I've set 3306 as an endpoint on the Azure VM
Despite all my attempts, the connection cannot be established. Is there something I'm missing on the setup?
As Azure VMs disable ICMP and we can use SSH tunnels to allow outside access to internal network resources. However I don’t have resource to create a DigitalOcean VM, but I have created 2 Azure VMs in 2 Cloud Services to try to reproduce the issue.
I installed mysql-server in VM.1 and mysql-client in VM.2.
Then I tried to connect MySQL server directly from VM.2, I got message “can’t connect to MySQL…”.
To work around this issue, I followed this post, created a SSH tunnel in VM.1 which hosted the MySQL server:
Open port 3306, so a remote client can connect to your MySQL Server. Run the following command to open TCP port 3306
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Now let’s check if the port 3306 is open by running this command:
sudo netstat -anltp|grep :3306
Create a SSH tunnel for port 3307
sudo ssh -fNg -L 3307:127.0.0.1:3306 azurevmuser#servername
Create an endpoint for the port 3307 in the dashboard of the VM in Azure management portal. For more details , See how to add endpoint to you Virtual machine. Now your Database host name is <vm_name>.cloudapp.net:3307
Then connect MySQL server from VM.2 using command:
# mysql -h <vm_1_name>.cloudapp.net -P 3307 -u user –pPassword
and it would work fine. Feel free to let us know if we have any misunderstood on your issue.
I am wondering if I can use ipython notebook remotely by ssh twice.
The scenario is: Machine B is the machine I want to run ipython notebook. However, I am only allowed to access machine B through another server (machine A) first.
There are tutorials about using ipython notebook remotely, but none of them mentions the situation I've encountered.
Thanks in advance !
Assuming you are referring to ssh tunnelling, and the ipython notebook is servering on port 1234 on machine B:
If machine A can access machine B on any port, you can setup machine A to forward a remote port to you via SSH:
ssh -L 9999:machineB.com:1234 -N machineA.com
This says
ssh to machineA.com without executing a remote command (-N) and setup machine A to forward requests from client port 9999, over an ssh tunnel, to machine B port 1234
However if machine A can only access machine B via ssh, then you will need to create two tunnels. One from your client PC to machineA, and another from machineA to machineB. To do this, the two tunnels connect to a local port on machineA instead of a remote port:
ssh -L 9999:localhost:8888 machineA.com ssh -L 8888:localhost:1234 -N machineB.com
This says
ssh to machineA.com and setup machine A to forward requests from our client PC port 9999, over an ssh tunnel, to machine A port 8888. Then execute the command "ssh -L 8888:localhost:1234 -N machineB.com". This command sets up a second tunnel from machineA port 8888 to machineB port 1234 (where iPython is listening).
Now, with that command running in the background, connect to your local PC port 9999. The first ssh tunnel will forward that request to machineA where it connects to localhost:8888, the second ssh tunnel will then forward it to machineB where it connects to localhost:1234.
Note that machineA will need to be able to connect to machineB automatically (using public/private key authentication) for this to work in a single command.
Here is a post that explains ssh tunnelling nicely https://superuser.com/questions/96489/ssh-tunnel-via-multiple-hops