Your script doesn't make sense, when you ssh you are attempting to start an interactive ssh session on a remote system. IF that worked (which it won't) then the script will present the user with a login prompt and then just sit there waiting for a password (or straight to a bash prompt if your'e using a key. The code you are apparently expecting to use to find the OS will NOT run on the remote server. At some point the ssh session will close, and when the ssh client process terminates, then the rest of the code will run on the LOCAL machine. This isn't going to do what you want.
update the ssh command to run uname there:
REMOTE_UNAME=$(ssh -p 56786 -l testuser $host uname -a)
then later in your code you can use that uname output as you see fit.