Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to ssh-j.com by code #1276

Open
paolobia opened this issue Dec 19, 2023 · 1 comment
Open

Connect to ssh-j.com by code #1276

paolobia opened this issue Dec 19, 2023 · 1 comment

Comments

@paolobia
Copy link

Hi, I try to write program for test to use ssh-j.com in my application

bug targetClient.Connect(); go timeout why ?

class Program
{
static void Main()
{
string path = System.IO.Directory.GetCurrentDirectory();
Console.WriteLine("Benvenuto nella simulazione di una shell SSH. Digita 'exit' per uscire.");
Console.WriteLine("Percorso corrente:" + path);
string jumpHost = "ssh-j.com";
string jumpUsername = "foo";
string jumpPassword = "";
string targetUsername = "paolob";
string targetPrivateKeyPath = "id_rsa"; // Percorso alla chiave privata del server di destinazione
PrivateKeyFile targetPrivateKey = new PrivateKeyFile(targetPrivateKeyPath);
using (SshClient jumpClient = new SshClient(jumpHost, jumpUsername, jumpPassword))
{
jumpClient.Connect();

         var jumpForwardedPort = new ForwardedPortDynamic("127.0.0.1", 22);
        jumpClient.AddForwardedPort(jumpForwardedPort);
        jumpForwardedPort.Start();

        PrivateKeyAuthenticationMethod am = new PrivateKeyAuthenticationMethod(targetUsername, targetPrivateKey);
        var connectionInfo = new ConnectionInfo(jumpForwardedPort.BoundHost, (int)jumpForwardedPort.BoundPort, targetUsername, am);

        using (SshClient targetClient = new SshClient(connectionInfo))
        {
            targetClient.Connect();
@Rob-Hague
Copy link
Collaborator

Hi, jump host (ssh -J option) is not currently implemented. I believe #954 aims to implement it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants