1

Is it possible to store ssh connection in bash script instead of $(ssh user@ip command) every time?

view story
linux-howto

http://unix.stackexchange.com – I think that the code that I already have is not very efficient as it has to connect each time to the same machine and execute a command. Code: tmp=$(ssh -nq $USER@$IP "$COMMAND" 2>> $LOG) tmp1=$(ssh -nq $USER@$IP "$COMMAND1" 2>> $LOG) tmp2=$(ssh -nq $USER@$IP "$COMMAND2" 2>> $LOG) tmp3=$(ssh -nq $USER@$IP "$COMMAND3" 2>> $LOG) Where $COMMAND in most of the cases is some kind of grep. Can I somehow store the ssh connection or refactor the code so it won't connect each time to the machine ? (HowTos)