Artificial intelligent assistant

ssh change user and execute command This is my command that I have in my script: ssh -i $KEY $USER@$HOST "sudo su tom; echo $DATA >> /home/user/file.txt These commands work fine on there own but together in the script it just hangs. If you run this command by itself `sudo su tom; cat /home/user/file.txt` It will only execute cat when you logout of the user tom. How do you change user and execute a command in a bash script ?

I was unable to switch users, executing as root seemed to do the trick.

`ssh -i $KEY $USER@$HOST "echo "$DATA" |sudo tee $DIRECTORY"`

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9c5fbfeb28c3269ea5560956d18e7e4a