0

I have been trying to execute a shell script with multiple approach but my script keeps getting stuck at the stage where it prompts to enter a password.

I have also tried to use Expect and Send the password but still not successful.

A very basic shell script I have is below

#!/bin/sh
mv text123.txt to test456.txt

sftp -P 2582 tuser@exemple.com

9874test---> This is the password 

cd route

put test456.txt 847c-43b2-8e50-0125n

The put command pastes the file to an account ID

The code renames the file then enters the connection details but gets stuck when its time to enter password.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
Pankaj Harde
  • 55
  • 1
  • 11
  • 1
    Do you mean that you have put the password in the script? – md2perpe Mar 23 '22 at 18:17
  • 4
    Do you know how to use private and public keys to automatically identify (commonly used with SSH)? – md2perpe Mar 23 '22 at 18:18
  • Yes I am trying to pass the password from the shell script, I am trying to execute these commands from an external linux VM, From this external VM I need to connect to the SFTP server to make the file transfer. While connecting to the SFTP server I need to pass the password which I am unable to pass. I am new to shell and the use of linux not much aware of how to use Private and Public Keys. – Pankaj Harde Mar 24 '22 at 02:53
  • 1
    I believe this thread will be able to help you out. [https://stackoverflow.com/questions/5386482/how-to-run-the-sftp-command-with-a-password-from-bash-script](https://stackoverflow.com/questions/5386482/how-to-run-the-sftp-command-with-a-password-from-bash-script) – imlowbatt Mar 24 '22 at 06:07

0 Answers0