How can I solve this problem? I have a bash script (under Ubuntu Server), doing several SSH connections, executes some remote transfers, like rsync multiple times.
My problem is, that I would like to avoid entering password multiple times. But I don't want to use SSH public key exchange, because if anybody has the key, will be able to connect the remote computer.
I would like the following:
- SSH should ask password when I start the bash script
- reuse password, so don't ask password again until timeout
- when timeout is over, ask password again.
Something similar, how sudo is working, just with ssh.
Any idea how to solve this?
EDIT1:
I found a new SSH feature named ssh multiplexing. Maybe using this I can reach the goal I want.
https://unix.stackexchange.com/questions/50508/reusing-ssh-session-for-repeated-rsync-commands
Would this work?
ssh-agent
to avoid needing to enter the passphrase every time, and the-t
option tossh-agent
will give you the timeout behavior you're after.