I am trying to use ssh unix command in X command in a SAS code , but it is not working, ssh is not able to connect to rmeote server
x 'ssh remote_server "cd dir1 ; mkdir abc"';
Anyone could help would be great
It means the place where the SAS program executes does not have the authentication to access the host. Perhaps your SAS is on a network drive? If so that network drive would need to have the host information setup on it. Speak to your IT group, they will be able to do that.
Have you tried this at a shell prompt? The first test would be to execute this command on the machine where your SAS code runs and as the user that runs the code. If you can connect bu get prompts than deal with those first. SSH should not prompt for password, passphrase or display some logon banner text. Use of a SSH key is in order. Only then you can hope it will work from SAS.
For further ideas I would like to see your error messages.
Regards,
- Jan.
Hi , I tried the ssh command on unix shell directly and it is working fine there , so this means I do have a succesful ssh set up but when i try the same command from SAS thru X , it does not work and in sas log it do not shows any ERROR messages too. Below is thecommand which i submitted on shell , apspt0152 is the remote server (password keys already set up) , and it is able to craete dir abc on apspt0152
ssh apspt0152 "cd /aalfmodl/Devki ; mkdir abc"
*******************************************************************************
* *
* This is a private computer system containing confidential information. *
* Any unauthorized attempt to access or use this computer system or any *
* information on it by employees or other persons may result in termination *
* of employment, civil fines, and criminal penalties. This system must be *
* used for authorized business purposes only. *
* *
*******************************************************************************
!!! This system is configured with LDAP authentication !!!
And does it work when run directly in your operating system? To be honest I don't see that command working as your not connected to anything or providing any connection details, but I am not a Unix user so don't know the application, but the examples I see online show:
ssh username@username.suso.org
as connection, then you pass other commands in. The answer is anyways, get the commands working at the command prompt then copy them into your SAS program.
hi
I am using this command where remote server is apspt0152 which is the actual hostname. the command is working fine at the shell but not is SAS code thru X
x 'ssh apspt0152 "cd /aalfmodl/Devki ; mkdir abc"';
You might want to read in the OS output to a dataset to see the results:
filname abc pipe 'ssh apspt0152 "cd /aalfmodl/Devki ; mkdir abc"';
data temp;
length res $2000;
infile abc dlm="¬";
input res $;
run;
Or simliar, you should then see the txt from the OS populated in a dataset. I would guess that your SAS system doesn't have the priviledges needed, i.e. SAS might be installed on a server or something.
Execute the operating system commands using a PIPE. Then you can read the messages that it sends.
data _null_;
infile 'ssh remote_server "cd dir1 ; mkdir abc"' pipe;
input;
put _infile_;
run;
Most likely you have either entered the hostname or path names incorrectly. But it might be that the process that is running your SAS program does not have permission to SSH to the remote or needs to supply a password.
It means the place where the SAS program executes does not have the authentication to access the host. Perhaps your SAS is on a network drive? If so that network drive would need to have the host information setup on it. Speak to your IT group, they will be able to do that.
Hi @devki
A few potential causes you may want to check:
grep AVC /var/log/audit/audit.log
You may need to ask your sysadmin to help on this, especially to resolve it if selinux is indeed at play. There are some sdelinux booleans that deterrmine how ssh behaves. Do this on the target server.
Furthermore make absolutely certain that your SAS code executes on the same host and same user as your shell tests. The client/server approach of Enterprise Guide or any use of grid servers may make this actually fuzzy.
Regards, Jan.
Hi Team
I am a little out of my element here, but depending on your access privileges you might try
'sudo ssh apspt0152 "cd /aalfmodl/Devki; mkdir thrupipe""
My understanding is that some commands require higher access priviledges and the DBA can give you 'super user do" authority for certain unix commands.
However it will prompt for your password. I have used this with 'full' SAS, but Ihave my doubts that it will work with EG, UE or SAS Studio.
Also you may need to know your 'lockdown' state.
Why do you need to create this folder? Can you use dcreate() function if SAS can see the server?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.