Where is wrong with my default value?

lyang0@lyang0-OptiPlex-755:/tmp$ ./fg.sh 
...............................
ssh to the guest .....
...............................
./fg.sh: 18: :ls: not found


lyang0@lyang0-OptiPlex-755:/tmp$ cat fg.sh 
#!/bin/sh
DEFAULT_CMD="ls /boot/"
ssh_to_guest()
{
        echo "..............................."
        echo "ssh to the guest ....."
        echo "..............................."
    CMD="$1"
    :${CMD:=$DEFAULT_CMD}
        if ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@128.224.165.205 "${CMD}";then
                echo "pass"
        else
                echo "fail"
        fi
        

}
ssh_to_guest

Try changing:

    CMD="$1"
    :${CMD:=$DEFAULT_CMD}

to:

    CMD=${1:-$DEFAULT_CMD}

I changed to yours

then run

./fg.sh ifconfig

it doesn't run ifconfig but still using default value

Sorry about that. Also change the last line from:

 ssh_to_guest

to:

 ssh_to_guest "$1"