BookmarkSubscribeRSS Feed
sun538
Obsidian | Level 7

We recently set up SFTP share for our team and tested the connection using windows PowerShell and it works properly (we can transfer the file). However, when we want to do SFTP sharing via SAS, it fails. Following is the code we use:

 

filename outfile sftp 'Transactions.csv' 
CD ='\\.....\folder\Transactions.csv' 
host="corpsftp.xxxxxx.com" 
user="xxxxxx"  
optionsx='-pw "xxxxx"'
DEBUG  ;

PROC EXPORT Data = TRAN_Final /* This is the dataset name */ 
OUTFILE= outfile 
DBMS=csv 
REPLACE;
Run;

However, we get the following error:

"Connection refused, check key authentication and sshd server status."

 

Since we are sure that connection works properly, can you please advise what causes this error to happen? Thank you.

4 REPLIES 4
Kurt_Bremser
Super User

You cannot supply a password to sftp via commandline (for security reasons). You must set up passwordless authentication with public/private keypairs first.

sun538
Obsidian | Level 7

Hi, Thank you for your response. Can you please advise where this private/public key should be created?

Kurt_Bremser
Super User

Depending on which software you have installed, this can help:

https://help.krystal.uk/cpanel-advanced-topics/how-to-use-public-private-keys-for-ssh-and-sftp-windo... 

 

You create a public/private keypair, install the public key in your .ssh subdirectory on the server, and the private key in your Windows client. The goal is to only supply the username and host to log in to the server from the commandline.

 

Your server/network admins should be able to assist you.

Sajid01
Meteorite | Level 14

Hello
The error is an indicator of an invalid key or sshd daemon not running on the server.
Please make sure that the same approach is being used in SAS as that in the Powershell script i.e. username/password OR private/Public key for authentication.
The following is an helpful SAS document, please do read if you have not done already.
https://support.sas.com/content/dam/SAS/support/en/technical-papers/configuring-ssh-client-software....

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2444 views
  • 0 likes
  • 3 in conversation