Using bastion jump host proxy gateway times out
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 4.4k
- Fork
- 993
- Merge medio
- 9g 21h
- PR unite (30g)
- 1
Descrizione
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*/}");
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non viene indicato alcun file sorgente né alcun test; inizia dalla costruzione di ConnectionInfo e dalla chiamata a SshClient.Connect, quindi traccia come è configurato il gateway rispetto al comando ssh -J funzionante. Il lavoro è completato quando la connessione equivalente al jump-host e la porta inoltrata vengono stabilite correttamente senza il timeout, seguite da una connessione Oracle.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100