BookmarkSubscribeRSS Feed
alr
Quartz | Level 8 alr
Quartz | Level 8

I need to use SFTP through a proxy server

I have found following example: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000178980.htm

 

Example 11: Using a Proxy Server

This example uses a proxy server with the FTP access method. The user ID and password are sent via the proxy server.

filename test ftp ' ' ls

   host='proxy.server.xxx.com'

   user='userid@ftpservername'

   pass='xxxxxx'

   cd='pubsdir/';

 

data _null_;

   infile test truncover;

   input a $256.;

   put a=;

run;

 

I have following scrip, which works fine but does not use a proxy server:

 

filename TEST SFTP '/MyFolder/'
     DIR FILEEXT LSA
     HOST = 'ftpservername'
     USER = 'Myuser'
     WAIT_MILLISECONDS = 5000
     LRECL = 2000
     OPTIONS = '-P 2222 -i \\myserver\PrivateKey.ppk -pw "xxxxx"'
     DEBUG
     ;

data _null_;
  infile TEST;
  input;
  FILE  'C:\Myfile.txt' ;
  put _infile_;
run;

I need to use a PROXY server with port number 8081.

I thought that I can change the code as follow but cannot figure out where to put the port number for the proxy server.

 

filename TEST SFTP '/MyFolder/'
     DIR FILEEXT LSA
     HOST     = 'proxy.server.xxx.com'
     USER    = 'Myuser@ftpservername'
     WAIT_MILLISECONDS = 5000
     LRECL    = 2000
     OPTIONS    = '-P 2222 -i \\myserver\PrivateKey.ppk -pw "xxxxx"'
     DEBUG
     ;

data _null_;
  infile TEST;
  input;
  FILE  'C:\Myfile.txt' ;
  put _infile_;
run;

Is this possible?

 

8 REPLIES 8
alr
Quartz | Level 8 alr
Quartz | Level 8

Yes, but then where can i provide the port number for the SFTP-server?
SFTP server use port 2222

Kurt_Bremser
Super User

Try this:

filename TEST SFTP '/MyFolder/'
     DIR FILEEXT LSA
     HOST     = 'proxy.server.xxx.com'
     USER    = 'Myuser@ftpservername:2222'
     WAIT_MILLISECONDS = 5000
     LRECL    = 2000
     OPTIONS    = '-P 8081 -i \\myserver\PrivateKey.ppk -pw "xxxxx"'
     DEBUG
     ;
alr
Quartz | Level 8 alr
Quartz | Level 8

Thank you but I stil get error.

 

ERROR: For further debugging assistance, insert the PSFTP verbose parameters
"options='-v' debug" on the Filename sftp statement and review the SAS log.
ERROR: Time-out on sftp server response. Increasing the value of the "wait_milliseconds"
       option might solve the problem.

 

I think it is because the password in Options is for the SFTP server and not for proxy server. Proxy server does not have a password.

 

WAIT_MILLISECONDS = 50000 not helping either.

alr
Quartz | Level 8 alr
Quartz | Level 8

adding -v on options give following error:

 

NOTE: psftp: Release 0.63

ERROR: Unable to launch the process; WriteFile returned rc 232 (The pipe is being closed.
).

 

Kurt_Bremser
Super User

I would tackle this from another end:

Start with getting the sftp running from the commandline; still better, start out with simple ssh

Options for ssh with a proxy are shown here:

https://stackoverflow.com/questions/19161960/connect-with-ssh-through-a-proxy

Once that works, you can use the same -o options with sftp.

Once that works, you can then use that commandline in a filename pipe to run the external command to retrieve the file to a local directory, from where you then read it.

filename sftp tends to not work with larger files over slower connections (it starts to read the file while it is still being copied, and can run into the end of the unfinished file prematurely). That's why I always call the sftp as an external command, and not with filename sftp.

alr
Quartz | Level 8 alr
Quartz | Level 8
Thank you, I'll try. I have to find out how to this in windows.
alr
Quartz | Level 8 alr
Quartz | Level 8
I will send an update when I find a solution. I can’t make the SFTP with command line to work.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 8 replies
  • 6818 views
  • 0 likes
  • 2 in conversation