I have gone through the link https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/
My requirement is that I want to push ssh command to remote server, So that will check current and installed kernel version on the remote server and have to reboot.
I have tried “su --session-command” combination also.
ssh anand@remote_host "su -lc 'if [ "`rpm -q kernel | tail -1`" == "kernel-$(uname -r)" ]; then echo "System is already running with latest kernel version"; else echo "reboot"; fi'"
Its taking variables where I pushing the command but I should take variables from remote server.
Thanks & Regards,