Page 1 of 1

SFTP - How to Use private certificate login

Posted: Thu Nov 12, 2020 3:25 am
by mjwsr1
I am trying to use a private key file to open sftp site. I am looking for an example of how to setup a sftp logon task using a key file.

Re: SFTP - How to Use private certificate login

Posted: Mon Nov 23, 2020 12:41 pm
by Oleg
Look at the example below, It works on our Ubuntu Server
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|592482493
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1213"
Hide=INTEGER|0
ID=INTEGER|-1053817032
LogOnAsUser=INTEGER|1
Name=STRING|"test loop (open SFTP with certificate)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_SFTP_LOGON"
Enabled=INTEGER|-1
Name=STRING|"SFTP Open (oleg@192.168.220.129)"
Params=FOLDER

[Actions\Action1\Params]
certfile=STRING|"D:\TEST\ssh-sftp\cert authentication\key20181031np.ppk"
host=STRING|"192.168.220.129"
password=STRING|"6840167175671736742767170"
port=STRING|"22"
usecertificate=STRING|"1"
username=STRING|"oleg"

[Actions\Action2]
ActionID=STRING|"A_SFTP_DIR"
Enabled=INTEGER|-1
Name=STRING|"SFTP File loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"18991230"
date2=STRING|"18991230"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
filenameonly=STRING|"0"
folder=STRING|"test/*.*"
kind=STRING|"0"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
sizesave=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subfolders=STRING|"1"
timesave=STRING|"0"
varname=STRING|"FILENAME"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action3\Params]
message=STRING|"{filename}"
type=STRING|"3"

[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
But please note that you have to prepare SSH Server to accept certificate.
How to do this read here, here and here

If server rejects certificate then you can login with username and password.