If you want to run curl
on the EC2 instance, and tunnel the output via ssh
, then try the following:
ssh ${USERNAME}@${EC2_INSTANCE_IP} curl -s http://localhost:8000/
You should see the result directly on the terminal (-s
will inhibit curl
's output).
You can run any command like this, there's nothing special for curl
.
If this works, then you can alter the curl
parameters to use -X POST
and/or -d
, along with the correct endpoint.
Please remember though, that 0.0.0.0
is a "special" address that actually means "listening on all interfaces"... So unless you configure the inbound rules correctly, anyone can still do curl http://${EC2_INSTANCE_IP}:8000/
and hit your server.
1Thanks for the help Attie, yes that's what I meant – anon – 2018-10-17T14:08:50.387
"listening on
0.0.0.0:8000
" means "listening on all interfaces" - so can you communicate with it on it's public IP? (the same you would use for SSH) – Attie – 2018-10-17T14:08:54.143Yes I think so Attie, when I start the server it just says:
no port specified, defaulting to port 8000
that lives in the ec2 instance. I would like to do thecurl -XPOST
from an "external machine" – anon – 2018-10-17T14:10:33.057I presume you are able to use SSH? Have you tried using
curl
with the same IP you used for SSH? – Attie – 2018-10-17T14:11:15.740No, could you provide an example attie? – anon – 2018-10-17T14:12:00.703
How are you managing the EC2 instance? SSH? – Attie – 2018-10-17T14:12:27.697
Possible duplicate of What is the cURL command-line syntax to do a POST request?
– Ahmed Ashour – 2018-10-17T14:19:19.823Its different because I would like to do it over ssh – anon – 2018-10-17T14:24:10.800