Using bastion jump host proxy gateway times out
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
I have verified that the following two lines work on fine on both my WSL2 (Linux on Windows) as well as Windows 10 (finally, Windows comes with ssh):
ssh -J user@1.2.3.4 user@5.6.7.8 -L 127.0.0.1:60006:9.10.11.12:1521 -fnNT
sqlplus myRdsUser/myRdsPass@127.0.0.1:60006/abc.defgh
I have also verified that,
if I start the ssh connection using
ssh -J user@1.2.3.4 user@5.6.7.8 -L 127.0.0.1:60006:9.10.11.12:1521 -fnNT
then the following code successfully connects and I'm able to query my database.
new OracleConnection($"Data Source={_hostConnectionProvider.GetHost()/*9.10.11.12*/}:{_hostConnectionProvider.GetPort()/*1521*/}/{config.ServiceName/*abc.defgh*/};User Id={config.Username/*myRdsUser*/};Password={config.Password/*myRdsPassword*/}");
But the equivalent .NET code times out (yes, I did kill the command line SSH connection first). The contents of my .ssh/id_rsa file is the same as what I'm passing into config.PrivateKey and I know it worked because I am able to connect to bastion/jump host/proxy/gateway directly using the private key as configured.
_logger.LogDebug("Getting config");
var config = options.Value;
_logger.LogDebug("Converting private key into memory stream");
var privateKeyStream = new MemoryStream(Encoding.UTF8.GetBytes(config.PrivateKey));
var privateKeyFile = new PrivateKeyFile(privateKeyStream);
var sshConnectionInfo = new ConnectionInfo(
config.DestinationHost, // 5.6.7.8
22,
config.DestinationHostUsername, // user
ProxyTypes.None,
config.GatewayHost, // 1.2.3.4
22,
config.GatewayHostUsername, // user
null,
new PrivateKeyAuthenticationMethod(config.DestinationHostUsername, privateKeyFile));
_sshClient = new SshClient(sshConnectionInfo);
_sshClient.Connect(); // This line throws after 30 seconds: System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
_sshForwardedPort = new ForwardedPortLocal("localhost", config.ProxyDestinationHost /*9.10.11.12*/, config.ProxyDestinationPort /*1521*/);
_sshClient.AddForwardedPort(_sshForwardedPort);
_sshForwardedPort.Start();
return new OracleConnection($"Data Source={_hostConnectionProvider.GetHost()/*9.10.11.12*/}:{_hostConnectionProvider.GetPort()/*1521*/}/{config.ServiceName/*abc.defgh*/};User Id={config.Username/*myRdsUser*/};Password={config.Password/*myRdsPassword*/}");
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named; start at the ConnectionInfo construction and SshClient.Connect call, then trace how the gateway is configured compared with the working ssh -J command. Done means the equivalent jump-host connection and forwarded port establish successfully without the timeout, followed by an Oracle connection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100