I have a lab environment where I can do various operations(GET, PUT, DELETE etc).
I do these in Postman using a URL similar to:
http://1.2.3.4:8338/accounts
This returns JASON containing account information.
I can also get this information with the following curl statement:
curl https://1.2.3.4:8338/accounts -u admin:Jpassword
I now want to do it in a remore environmnet that I have to access through a jump server. I previously did something similar. I used SSH Tunnel Manager to create the connection. This is what it looked like. 1.1.1.1 is the jump server IP and 1.2.3.4 is the server I'm looking to connect to.
ssh -N -p 22 username#1.1.1.1 -o StrictHostKeyChecking=no -L 1.1.1.1:8080:1.2.3.4:443
I can then access through postman or my browser using the following URL:
https://127.0.0.1:8080/
I want to do the same with except I must specify port 8338. If I follow the same steps but use port 8338 instead of 8080 I get a 403 response when I try my url. If I change port 443 to 8338 I also get also get a 403.
I was wondering if this is likely to be an authentication issue or something I'm doing wrong with my tunnel.
Found the answer.
My problem was that I was using a wrong port. I should have had port 8338 instead of 443.
ssh -N -p 22 username#1.1.1.1 -o StrictHostKeyChecking=no -L 1.1.1.1:8080:1.2.3.4:8338
Now I can connect with this URL:
http://1.2.3.4:8080/accounts
Related
I have been working on a batch script for some automation in the workplace. We have a Watchguard firewall and I need to sign in via batch. My present solution is sending a cURL POST request with the details needed. This is what I am calling:
set address="https://watchguard.<domain>:4100/wgcgi.cgi"
set data="fw_username=<username>&fw_password=<password>&fw_domain=<domain>&submit=Login&action=fw_logon&fw_logon_type=logon"
curl -k -m 10 -X POST -d %data% %address%
I have left the domain, username and password out for security reasons. This works almost all the time, however occasionally the cURL request hangs indefinitely despite the -m flag used. This has, so far, only occurred after the computer's 8 hour Watchguard session has expired though this doesn't always cause the issue. Once the issue shows up, it continues to happen until the machine is restarted.
This issue seems to be correlated with a similar issue on Internet Explorer. Internet Explorer hangs indefinitely while trying to open any webpage. Chrome, Edge and Firefox have no issues loading webpages. I was tipped off to the association between cURL and Internet Explorer because of this thread: https://curl.se/mail/lib-2012-10/0184.html
When I run curl -v -m 10 -X POST -d %data% %address% (with -v but no -k). Doing this gives me the following output:
* Trying <Firebox IP>...
* TCP_NODELAY set
* Connected to watchguard.<domain> (<Firebox IP>) port 4100 (#0)
* schannel: SSL/TLS connection with watchguard.<domain> port 4100 (step 1/3)
* schannel: checking server certificate revocation
When I run curl -v -k -m 10 -X POST -d %data% %address% (with -v). Doing this gives me the following output:
* Trying <Firebox IP>...
* TCP_NODELAY set
* Connected to watchguard.<domain> (<Firebox IP>) port 4100 (#0)
* schannel: SSL/TLS connection with watchguard.<domain> port 4100 (step 1/3)
* schannel: disabled server certificate revocation checks
* schannel: verifyhost setting prevents Schannel from comparing the supplied target name with the subject names in server certificates.
Is there something that I can do to make sure it goes through successfully?
cURL version:
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: 2017-11-14, security patched: 2019-11-05
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
Watchguard version:
WatchguardFireBox M670 running Fireware OSv12.6.2.B631387
I am using mongo 3.0.8. I have an authenticated user admin with password admin. I am able to connect to the mongo shell as follows.
mongo admin -u amdin -p amdin
However, i tried to connect to using the following C code. This gives me an error
WARNING: client: Failed to connect to: ipv4 127.0.0.1:27017,
error: 111, Connection refused
char URI[256];
snprintf(URI,256,"mongodb://admin:admin#127.0.0.1:27017/?authSource=admin");
mongoc_client_t *client = mongoc_client_new(URI);
The error error: 111, Connection refused is a networking error.
Your URI expecting to find the server listening on port 27017 of the same machine (127.0.0.1). Possible issues:
Server not running
Server not on that port
Server is bound to the "real ip address" of the machine.
There is local firewall (e.g. iptables) blocking access
Maybe an SELinux problem?
If this is a Linux box, these commands might help diagnose:
netstat -an -A inet | grep LISTEN
/sbin/iptables -L
I have an Apache2 Ubuntu Server that is running and want to replicate my couchDB database locally to remote on the server. With terminal curl from this documentation on how to replicate. I performed this:
curl -X POST -d '{"source":"http://127.0.0.1:5984/demo","http://server_IP_here/":"demo"}' \http://127.0.0.1:5984/_replicate
The error comes up everytime. Is there something wrong with the above statement?
The server IP has doesn't require ports as a side not.
curl: (7) Failed to connect to 127.0.0.1 port 5984: Connection refused
Try to use port 8092
I couldn't found documentation on this, though random trying different ports found that my couchbase instance answer there :)
Suppose I've managed to get the server up and running by executing:
./foo [portno] [args]
How do I telnet into the server on the local machine?
I tried the following:
telnet localhost [portno]
ERROR: localhost: nodename nor servname provided, or not known
telnet [portno]
ERROR: Trying 0.1.226.65...
telnet: connect to address 0.1.226.65: No route to host
telnet: Unable to connect to remote host
Try this:
telnet 127.0.0.1 [portno]
You should have something like the following in your /private/etc/hosts in order for localhost to work:
127.0.0.1 localhost
Also, make sure that you run telnet 127.0.0.1 123 and not telnet 127.0.0.1:123 (where 123 is the port).
How do you test to see if your program is working and able to connect with server? I tried stackoverflow server's ip through port 40 and it fails after a min at connect().
test.exe 64.34.119.12 echo 40
Program arguments take a syntax: <Server IP> <Echo Word> [<Echo Port>]
Also, can you test without having to connect to internet?
You should be able to connect to your own echo server on 127.0.0.1:7 if it is running, or get a 'connection refused' (ECONN) if it isn't running. Either would show that your code is OK actually.
As for testing without having to connect to the internet...
I'd download netcat for windows.
NetCat download
Extract the tool, and run:
nc.exe -v -l -p [port]
If you do that, it opens up a "server" and you can connect to it using your application; just point the IP address to 127.0.0.1!