D
D
Dmitry Kulikov2016-04-29 09:26:57
*nix-like systems
Dmitry Kulikov, 2016-04-29 09:26:57

How to add password input to shell script?

Hello.
I used a similar code to download archives from the server

#!/bin/sh
HOST="host"
PORT="21"
USER="user"
PASSWD="pass"

FILE="dir"
UFILE="dir"
ftp -n $HOST $PORT <<EOF
quote USER $USER
quote PASS $PASSWD
bin
get $FILE $UFILE
quit
EOF

exit 0

But as the files began to grow, I realized that this script has its limitations and decided to look towards ssh.
scp [email protected]:/dir /dir
But here I still need to transfer a password, and here Google let me down, I can’t find a single example with a password, who can tell me how to do it right similar request from a script?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fogersp, 2016-04-29
@fogersp

For example : rizloff.com/linux/ssh-login-without-password-use-a ...

sshpass -p пароль scp -o StrictHostKeyChecking=no -r [email protected]:/home/foger/file.txt ./

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question