sshj
sshj copied to clipboard
session.setEnvVar throws ConnectionError
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
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.
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.
Which version of sshj?
Op do 5 nov. 2015 20:56 schreef James Poulsen [email protected]:
I too am running into this issue. Any idea of a temporary work-around?
— Reply to this email directly or view it on GitHub https://github.com/hierynomus/sshj/issues/128#issuecomment-154172740.
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.
Anyone found the solution for this?
As far as I know the server should allow setting environment variables. For OpenSSH it should be set in /etc/sshd_config.
@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 [email protected]:
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).