BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
devki
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

14 REPLIES 14
jklaverstijn
Rhodochrosite | Level 12

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.

devki
Calcite | Level 5

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 !!!

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

devki
Calcite | Level 5

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"';

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Tom
Super User Tom
Super User

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.

devki
Calcite | Level 5
Hi Tired this :
data _null_;
infile 'ssh apspt0152 "cd /aalfmodl/Devki; mkdir thrupipe"' pipe;
input;
put _infile_;
run;

and in the sas log :
NOTE: AUTOEXEC processing completed.

1 data _null_;
2 infile 'ssh apspt0152 "cd /aalfmodl/Devki; mkdir thrupipe"' pipe;
3 input;
4 put _infile_;
5 run;

NOTE: The infile 'ssh apspt0152 "cd /aalfmodl/Devki; mkdir thrupipe"' is:
Pipe command="ssh apspt0152 "cd /aalfmodl/Devki; mkdir thrupipe""

Host key verification failed.
2 The SAS System 08:00 Tuesday, June 14, 2016

NOTE: 1 record was read from the infile 'ssh apspt0152 "cd /aalfmodl/Devki; mkdir thrupipe"'.
The minimum record length was 29.
The maximum record length was 29.
NOTE: DATA statement used (Total process time):
real time 0.36 seconds
cpu time 0.00 seconds

I am not sure what does this means here "Host key verification failed. "
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

devki
Calcite | Level 5
The unicx ID which I was using did not had proper access to the SAS server , had to work with unix and IT admins for the same and then the pipe method using SSH command was working perfectly.. Thanks guyz for all the help ...
jklaverstijn
Rhodochrosite | Level 12

Hi @devki

 

A few potential causes you may want to check:

 

  • Try adding the -o 'StrictHostKeyChecking=no' to the ssh command. Also add -o 'LogLevel quiet' to suppress the welcome banner
  • Check to see if selinux, if enabled, is blocking you. I have seen this happening where on the shell it works and from scripting not: 
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.

rogerjdeangelis
Barite | Level 11

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. 

Reeza
Super User

Why do you need to create this folder? Can you use dcreate() function if SAS can see the server?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 5036 views
  • 3 likes
  • 7 in conversation