I'd prefer to use awk instead of cut (if possible), to avoid problems with having more than one space or having tabs.

    local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'