Hi all,
i have a strange behavior and i think it must have something to do with the SSH Session in SSHLibrary.
So i have a host where i use jfrog-cli to download artifacts from artifactory using this command
CI=true JFROG_CLI_TEMP_DIR=/var/lib/kvmd/msd/ /opt/jf rt download ....
I’m using this for 2 years now without any problem.
For this i use Execute Command from SSHLibrary to run the command. Of course i first do a “Open Connection and Login In” and “Login” with user name and password. In the RF-Logs i can see the login. All good.
Now because of infrastructure changes i have to use a PROXY on the host where i execute the jfrog-cli command. BUT because my jfrog-cli command is used with an internal server i DON’T have to use the proxy that’s why my internal server is on the list for “NO_PROXY”
For this i have setup on my host the /etc/environment as follows
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#
export https_proxy="http://x.x.x.x:8080"
export HTTPS_PROXY=$https_proxy
export http_proxy="http://x.x.x.x:8080"
export HTTP_PROXY=$http_proxy
export no_proxy="localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,foo.bar"
export NO_PROXY=$no_proxy
AND i also have done changes to ~/.bashrc and put this
if [ -f /etc/environment ]; then
. /etc/environment
fi
Now if i reboot my device and if i use putty to connect via ssh - EVERYTHING IS WORKING!!
I can dl my artifacts and to test proxy you can use a “ping” like this
/opt/jf rt ping
Again - using putty or using ssh from my ubuntu and connect to my device everything is working fine.
But now using SSHLibrary and Execute Command i get an error on stderr like this
${stderr} = 11:34:51 [Warn] (Attempt 1) - Failure occurred while sending POST request to
This error appears when the /etc/environment is NOT set or is not present in the ssh session.
To me it looks like the SSHLibrary Open Connection Login will create a ssh session and login BUT for some reason the host proxy settings are NOT effective for these kind of ssh sessions.
Does anyone have an idea?
So far i tried to execute “env” first to check the variables for environment and to execute
source /etc/environment
to reload the environment.
Executing “env” i do see that the proxy ARE SET !!! See
['SHELL=/bin/bash\nno_proxy=localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,foo.bar\nPWD=/root\nLOGNAME=root\nMOTD_SHOWN=pam\nHOME=/root\nhttps_proxy=http://x.x.x.x:xxxx\nSSH_CONNECTION=x.x.x.x 62931 x.x.x.x 22\nUSER=root\nNO_PROXY=$no_proxy\nSHLVL=0\nHTTPS_PROXY=$https_proxy\nHTTP_PROXY=$http_proxy\nhttp_proxy=http://x.x.x.x:xxxx\nSSH_CLIENT=x.x.x.x 62931 22\nPATH=/usr/local/sbin:/usr/local/bin:/usr/bin\nMAIL=/var/spool/mail/root\n_=/usr/bin/env', '0']
Chatgpt told me to set the proxy env variables to my execute command like this - but i’m not sure if this will work (shall i try?)
*** Settings ***
Library SSHLibrary
*** Variables ***
${REMOTE_HOST} your.remote.host
${REMOTE_USER} your_username
${REMOTE_PASSWORD} your_password
${HTTP_PROXY} http://proxy.example.com:8080
${HTTPS_PROXY} http://proxy.example.com:8080
${NO_PROXY} localhost,127.0.0.1
*** Test Cases ***
Test Command With Proxy
Open Connection ${REMOTE_HOST}
Login ${REMOTE_USER} ${REMOTE_PASSWORD}
${command}= Set Proxy Command curl -I http://example.com
${output}= Execute Command ${command}
Log ${output}
Close Connection
*** Keywords ***
Set Proxy Command
[Return] export http_proxy=${HTTP_PROXY} && export https_proxy=${HTTPS_PROXY} && export NO_PROXY=${NO_PROXY} && curl -I http://example.com
Any help is welcome
Br,
Camil