I am using sftp in batch script for which all configuration for public/private keys are done and it works fine without asking a password. No issues till this point. Now I the problem I have is that if the password expires/someone changes the authentication keys at reote server then the scripts asks for the password prompt and the process waits there. No error is thrown, it just stop with asking a password.
I want to handle these kind of scenarios so that if any of the above situation (password expires/someone changes the authentication keys) occur then some error should result or I should get proper exit status.
It works fine if proper setup of keys is done. If I play around the key than again it wait with password prompt.
Then I chaged the main script as:
sftp -b commands.sh server
but then i have new problem that it tries to connect with the user from which I am currently logged in which actually is not the correct user to connect with and this is obvious error.