I want to store all servers in the local server(Linux Jumpbox), so I can connect by simply searching for specific hostname and ssh remotely from my Linux jump box.
So, the requirement is, input the server hostname, which should search in existing server list, if found, perform ssh connection, if not found, store under specific folder and perform ssh connection.
I tried the following simple if condition, but I actually want to categorize store servers under DEV, QA, UAT, PROD etc., using either under folder or LABEL.
Please share your suggestions/recommendations best way to manage the server list. Also suggest whether IF or CASE would be better approach for this.
***Script****
#!/bin/bash
if test -f /home/oracle/remote_hosts.lst
then
echo "The File /home/oracle/remote_hosts.lst exists"
else
echo "The File /home/oracle/remote_hosts.lst does not exist"
exit 1
fi
echo "Please enter the Host Name of Remote Host System: \c"
read rhost
if grep $rhost /home/oracle/remote_hosts.lst 1> /dev/null 2>&1
then
ssh -l oracle $rhost
else
echo $rhost >> /home/oracle/remote_hosts.lst
ssh -l oracle $rhost
fi