0

I'm fairly new to unix scripting and right now I'm modifying this existing FTP line of code found below. I need it to automatically insert the password after accessing a specific bridge server. After successful input of password, the script will automatically send and acknowledgment file ($acknFile) to that bridge server.

I have read different articles and forums and a lot of them suggests on using Expect as a solution. But I was advised that we just need to use whatever module we have and unfortunately, Expect is not included. Will highly appreciate any input from you guys and will try to understand how it works.

See line of code below:

if grep -q "$Filename" "$FilenameDirectory"
then
echo "File exists." >> $acknFile
scp - v $acknFile "$BridgeServer"
else
echo "File does not exists."
fi

1 Answer 1

3

You are using scp which uses ssh not ftp.

scp wants the password for an ssh session. If you want scp not to ask for password you can authorize your account to use password-less logins. For that you do the following in the local host.

Step 1: Create public and private keys using ssh-key-gen on local-host

$ ssh-keygen

Step 2: Copy the public key to remote-host using ssh-copy-id

$ ssh-copy-id user@remote-host

Step 3: Check login to remote-host without entering the password

$ ssh user@remote-host
Sign up to request clarification or add additional context in comments.

2 Comments

if I'll authorize my account to use password-less logins, will there be any issues in the future since I will not be the only one using this script as far as my concern. This will be deployed on different environments.
If others will be using this script than you can look at the link unix.stackexchange.com/questions/60544/… . If number of users who will use your script is fixed you can give specific command= in front of the keys, otherwise make the script with your effective uid, then anyone can execute the script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.