Professional Documents
Culture Documents
StackOverflowisaquestionandanswersiteforprofessionalandenthusiastprogrammers.It's100%free.
Howtosendpasswordusingsftpbatchfile
I'mtryingtodownloadafilefromsftpsiteusingbatchscript.I'mgettingthefollowingerror:
Permissiondenied(publickey,password,keyboardinteractive).
Couldn'treadpacket:Connectionresetbypeer
Whenrunningthecommand:
sftpb/home/batchfile.sftp<user>@<serverip>:<folder>
the
batchfile.sftp
includesthesedata:
password
lcd[localfolder]
cd[sftpserverfolder]
get*
bye
Note:It'sworkingwhenrunningatthepromptas
sftp<user>@<serverip>:<folder>
ButIneedtheabilitytoenterthepasswordautomatically.
batchfile passwords sftp
editedJul16at16:17
askedJul31'12at10:33
Pi
8,302
judith
17
63
129
145
14
1 Isitworking,byremovingthepasswordfromthebatchfile?Doestheremainingfunctionalityworkwell,by
enteringthepasswordmanually?mtk Aug1'12at8:03
Storingthepasswordinplaintextinafileisobviouslynotsecureifyoudon'twanttotypeinapassword
everytimeIstronglysuggestusingRSAkeyauthentication.lindheNov1'14at0:15
4Answers
You'llwanttoinstallthesshpassprogram.Then:
sshpasspYOUR_PASSWORDsftpoBatchMode=nobYOUR_COMMAND_FILE_PATHUSER@HOST
Obviously,it'sbettertosetuppublickeyauthentication.Onlyusethisifthat'simpossibletodo,
forwhateverreason.
answeredFeb1'14at4:56
JoeVanDyk
3,222
30
Thankyou!Thisistheonlycommentthatactuallyanswersthequestion.Therearetimesit'ssimplynot
possibletogetakeyfile.jbrownApr29at14:40
Ifyouaregeneratingaheapofcommandstoberun,thencallthatscriptfromaterminal,youcan
trythefollowing.
sftplogin@host</path/to/command/list
Youwillthenbeaskedtoenteryourpassword(aspernormal)howeverallthecommandsinthe
scriptrunafterthat.
Thisisclearlynotacompletelyautomatedoptionthatcanbeusedina
cron
job,butitcanbe
54
login
tour
help
stackoverflowcareers
Signup
usedfromaterminal.
answeredFeb6'14at0:47
Tigger
2,567
14
20
Iadviseyoutorunsftpwithvoption.Itbecomesmucheasiertofathomwhatishappening.
Themanualclearlystates:
Thefinalusageformatallowsforautomatedsessionsusingtheboption.Insuchcases,itis
necessarytoconfigurenoninteractiveauthenticationtoobviatetheneedtoenterapassword
atconnectiontime(seesshd(8)andsshkeygen(1)fordetails).
Inotherwordsyouhavetoestablishapublickeyauthentication.Thenyou'llbeabletorunabatch
script.
P.S.Itiswrongtoputyourpasswordinyourbatchfile.
editedJul21'13at1:04
answeredJul21'13at0:58
akond
7,195
16
36
Youmentionbatchfiles,amIcorrectthenassumingthatyou'retalkingaboutaWindowssystem?
Ifsoyoucannotusesshpass,andyouwillhavetoswitchtoadifferentoption.
Twoofsuchoptions,thatfollowdiametricallyoppositephilosophiesare:
psftp:commandlinetoolthatyoucancallfromwithinyourbatchscriptspsftpispartofthe
PuTTYpackageandyoucanfindithere
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Syncplify.meFTPScript:ascriptableFTP/SandSFTPclientforWindowsthatallowsyouto
storeyourpasswordinencrypted"profilefiles"checkitouthere
http://www.syncplify.me/products/ftpscript/
Eitherway,switchingfrompasswordtoPKIauthenticationisstronglyrecommended.
editedMay18at16:55
answeredOct12'14at16:12
FjodrSo
66