ssh -t -q oracle@pm "(df -h /u02; hostname -f; date)"
read -p "enter server name: " server ; ssh -t -q $server "(sudo -iu oracle)"
or looping multiple servers :-
for servers in server1 server2 server3 server4 ;
do
ssh -t -q $servers "(df -h /u02; hostname -f ; date)" ;
done;
EXPLANATION:-
ssh: This is the SSH command used for secure remote shell access.-t: This option is used to allocate a pseudo-terminal. It's often necessary when you want to run interactive commands remotely because it simulates an interactive terminal session.-q: This option stands for "quiet" and is used to suppress warning and diagnostic messages. It makes the SSH command less verbose.oracle@pm: This part specifies the username (oracle) and the hostname or IP address (pm) of the remote server you want to connect to. The@symbol separates the username from the hostname."(...)": The parentheses enclose a series of commands that you want to execute on the remote server. In this case, three commands are enclosed:df -h /u02,hostname -f, anddate.-toption is essential when running multiple commands, as it ensures that the commands are executed in an environment that behaves like an interactive shell session.