Wednesday, April 2, 2014

Failed to transfer file with SFTP in batch mode

There is a problem when I transferring files over SFTP in batch mode. Say I have the file transfer script that do this:
sshpass –e sftp –b filelist.txt theuser@123.123.12.123:/home/theuser << EOF
bye
EOF
Assuming there is no problem found in filelist.txt, if the file transfer script is execute, the following error would be seen:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Couldn't read packet: Connection reset by peer


Running the sftp command with –v option shows that it seems not able to find the key pair for authentication. Later I found out that missing oBatchMode option may failed the process, thus this should be the work around I found in forum.
sshpass –e sftp –oBatchMode=no –b filelist.txt theuser@123.123.12.123:/home/theuser << EOF
bye
EOF

No comments: