How to get the IP address from $SSH_CLIENT
sshvars=($SSH_CLIENT)
echo "${sshvars[0]}"
or:
echo "${SSH_CLIENT%% *}"
you can use set --
eg
$ SSH_CLIENT="10.0.40.177 52335 22"
$ set -- $SSH_CLIENT
$ echo $1 # first "element"
10.0.40.177
$ echo $2 # second "element"
52335
$ echo $3
22
For strings, as is the case here, the <<<
operator may be used:
$ read ipaddress outport inport <<< $SSH_CLIENT
See e.g: Linux Bash: Multiple variable assignment. Don't do this with binary input though: Is there a binary safe <<< in bash?