0

I need to connect to a server "[email protected]" through a jump server "[email protected]" to which I already have access from localhost.

I have tried,

ssh -L 12345:[email protected]:80 user@[email protected] -i /path/id_rsa

In a different terminal when I now try

curl  -I http://localhost:12345/home/value

I get

Server: awselb/2.0
Date: Mon, 28 Sep 2020 13:58:25 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive

I already have access to jump server and the following works ,

ssh -i /path/id_rsa user@[email protected]

curl [email protected]/home/value  // gives me the required result

PS: I have also tried the same with Jsch

 String rhost = "[email protected]";
 int rport = 80;

 url = "http://localhost:";
 JSch jsch = new JSch();
 jsch.addIdentity("~/.ssh/id_rsa");
 String host = "[email protected]";
 String userJsch = "user";
 java.util.Properties config = new java.util.Properties();
 config.put("StrictHostKeyChecking", "no");
 Session session = jsch.getSession(userJsch, host, 22);
 session.setConfig(config);

 session.connect();

 int assinged_port = session.setPortForwardingL(0, rhost, rport);
 url = url + assinged_port + "/";
 String endpoint = url + "quote/home/value";
 ResponseEntity<String> response = restTemplate.getForEntity(endpointemphasized text, String.class);

This also gives 404.

  • 4
    Does this answer your question? [Why does the original site work, but port forwarding to the same site fails?](https://superuser.com/questions/1541704/why-does-the-original-site-work-but-port-forwarding-to-the-same-site-fails) – Kamil Maciorowski Sep 29 '20 at 06:29
  • 1
    Not an exact duplicate, but there's an explanation and plenty of curl examples here: [Replace server address by IP in curl](https://superuser.com/q/1587335/194694) – gronostaj Sep 29 '20 at 06:48
  • Yes @KamilMaciorowski and gronostaj I could solve the issue by providing the Host key. Thank you !! – Ashwin Sreekumar Sep 30 '20 at 11:21

0 Answers0