How to pass password as a variable for sshpass authentication?

Using below below command i'm able to connect or authenticate server, In below command password contains special characters

sshpass -v  -p 'ASJBA%hs76)#' ssh -q -o ConnectTimeout=5 hostname

But If I pass password as a variable I'm not able to connect or authenticate server, can you please help me to fix this

sshpass -v  -p $password ssh -q -o ConnectTimeout=5 hostname
cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4

Have $var in quotes: "$password"

2 Likes