- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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"';
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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. "
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Why do you need to create this folder? Can you use dcreate() function if SAS can see the server?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
https://communities.sas.com/t5/SAS-Procedures/Create-a-directory-on-UNIX/td-p/85207