在环境变量中设

declare -x SSHPASS="密码"

sshpass -e ssh -o StrictHostKeyChecking=no 用户名@IP "free|grep Mem" > $tempfile