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

session.setEnvVar throws ConnectionError #128

Open
selimober opened this issue Feb 17, 2014 · 7 comments
Open

session.setEnvVar throws ConnectionError #128

selimober opened this issue Feb 17, 2014 · 7 comments
Labels

Comments

@selimober
Copy link

I'm testing to connect to localhost.
I manage to connect and execute a command without session.setEnvVar.

With session.setEnvVar enabled it throws:

net.schmizz.sshj.connection.ConnectionException: Request failed
at net.schmizz.sshj.connection.channel.AbstractChannel.gotResponse(AbstractChannel.java:401)
at net.schmizz.sshj.connection.channel.AbstractChannel.handle(AbstractChannel.java:204)
at net.schmizz.sshj.connection.ConnectionImpl.handle(ConnectionImpl.java:128)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:475)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:127)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:195)
at net.schmizz.sshj.transport.Reader.run(Reader.java:72)

The code is as follows:

    SSHClient ssh = new SSHClient();
    ssh.addHostKeyVerifier(new PromiscuousVerifier());
    ssh.connect("192.168.1.99"); //localhost
    TaskRunResponse response;
    try {
        ssh.authPassword("user", "pwd");
        Session session = ssh.startSession();
        try {
            session.setEnvVar("testenv", "123");
            Session.Command cmd = session.exec("/Users/selimober/tmp/paramandenvtest.sh 10");
            cmd.join();
            String output = IOUtils.readFully(cmd.getInputStream()).toString();
            Integer exitStatus = cmd.getExitStatus();
            response = new TaskRunResponse(ExitStatus.SUCCESS, output);
        } finally {
            session.close();
        }
    } finally {
        ssh.disconnect();
    }

Version: net.schmizz:sshj:0.9.0
Server: SSH-2.0-OpenSSH_6.2

@mdwn
Copy link

mdwn commented Apr 23, 2015

I'm running into this issue as well. Currently in the thick of a deadline, but I'll try to help debug/fix this when I get some downtime here.

@Jepod
Copy link

Jepod commented Nov 5, 2015

I too am running into this issue. Any idea of a temporary work-around?

I'm connecting to a CentOS 6.6 running OpenSSH 5.3p1 if this helps.

@hierynomus
Copy link
Owner

Which version of sshj?

Op do 5 nov. 2015 20:56 schreef James Poulsen notifications@github.com:

I too am running into this issue. Any idea of a temporary work-around?


Reply to this email directly or view it on GitHub
#128 (comment).

@Jepod
Copy link

Jepod commented Nov 5, 2015

I meant to say that too, sorry. It's version SSHJ 0.14.0.

However, I'm starting to think it's not a bug in SSHJ as I can't use Putty to set environmental variables on initial connection either. I'm going to look into this further.

@adraghici
Copy link

Anyone found the solution for this?

@Tuchkata
Copy link

As far as I know the server should allow setting environment variables. For OpenSSH it should be set in /etc/sshd_config.

@adarshhm6
Copy link

adarshhm6 commented Dec 28, 2022

@hierynomus I am facing this issue in CentOs 7 with SSHJ version 0.31.0. Any alternative solution for this issue to set envVars while executing the command?

Which version of sshj?

Op do 5 nov. 2015 20:56 schreef James Poulsen notifications@github.com:

I too am running into this issue. Any idea of a temporary work-around?

Reply to this email directly or view it on GitHub
#128 (comment).

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

No branches or pull requests

8 participants