Making some assumptions here:
- remote machine is accessible from local one under IP
1.2.3.4
1.2.3.4
has SSH up and running on open port 22- you know the password of user
foobar
on1.2.3.4
To copy the script to foobar's home directory:
scp /path/to/script.sh foobar@1.2.3.4:~/
Adding executable permissions to the script and running it:
ssh foobar@1.2.3.4 "chmod +x ~/script.sh"
ssh foobar@1.2.3.4 "~/script.sh"
If you need to do this often/automatically, read up about setting up SSH keypairs for a passwordless login. And DO NOT store your password as plaintext in a script, as it presents a serious security risk - SSH keys were made just for this purpose.