Try this, not tested. I am assuming that ssh passwordless is setup
for h in AIXMC01 AIXMC02 AIXMC03 AIXMC04
do
ssh $h lsattr -Elsys0 | awk -v h=$h '
BEGIN { print "Hostname Modelname SerialID" }
$1=="systemid"{s=$2}
$1=="modelname"{m=$2}
END {print h,m,s}'
done
Each box has username and password and password changes every 60 days; I can hardcode the username and passwd.
Thanks,
---------- Post updated at 10:49 AM ---------- Previous update was at 10:43 AM ----------
If run the script just for one box AIXMC01 (local; not remote) it prompt for passwd.
---------- Post updated at 10:49 AM ---------- Previous update was at 10:49 AM ----------
If run the script just for one box AIXMC01 (local; not remote) it prompt for passwd.
---------- Post updated at 11:00 AM ---------- Previous update was at 10:49 AM ----------
The problem is i cant hardcode the passwd for each box using my own userid; each box use secure ID.
secure ID contain 6digit + PIN.
But the best solution is I can get root passwd for each box;
I would like to hard code root passwd; root passwd dont required secure ID but they changes every 30 days; when they change I will change the script.
You don't have to hardcode the password. Keys are a separate mechanism. Changing the password doesn't break the key. Google 'passwordless ssh' and you'll find hundreds of examples.
This is much easier than trying to inject plaintext passwords into a script, too, because ssh(and most other sane authentication systems) is designed to prevent that for security reasons.
Actually I found a way to ssh without passwd to any remote boxes.
the following command " sudo su - "
now please help me to to put this logic (sudo su - ) in above script so that I can access each boxes.
As I mentioned passwordless ssh already in place.
When I enter : sudo su -
I can ssh to any boxes I like.
I need help to add sudo su - logic in the script for each boxes.
for h in AIXMC01 AIXMC02 AIXMC03 AIXMC04
do
ssh $h lsattr -Elsys0 | awk -v h=$h '
BEGIN { print "Hostname Modelname SerialID" }
$1=="systemid"{s=$2}
$1=="modelname"{m=$2}
END {print h,m,s}'
done
Thanks,
---------- Post updated at 03:00 PM ---------- Previous update was at 02:45 PM ----------
the above script works fine when I logged as a root. the only problem I have
I dont want the heading for each boxes. As you can see "Hostname Modelname SerialID
" is repeating