Results 1 to 8 of 8
So, right now I'm trying to make an SSH script for my place of employment. This script, I want to go out to the server hostnames we have specified (in ...
- 05-11-2010 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 24
ssh script
So, right now I'm trying to make an SSH script for my place of employment. This script, I want to go out to the server hostnames we have specified (in another file) and change a users account password. We use Kerberized telnet, so if telnet root hostname fails, I want it to use ssh username hostname and use the old password (specified). If both fail, I want it to ask the user what the port should be and input the port in the ssh command.
But I'm having a issue having it try telnet root hostname and if it fails then, try to ssh in, I have no clue how to have it proceed. Is it an if statement?
Here's the telnet failed message:
telnet: Unable to connect to remote host: Connection refused
So if it sees refused, then it goes to ssh (maybe?)
Thanks!!
- 05-11-2010 #2
I can't understand your problem exactly. Why you want to use telnet? ssh won't be enough?
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-11-2010 #3Just Joined!
- Join Date
- Jul 2009
- Posts
- 24
How my company works, we use kerb telnet on some boxes and some don't have it installed, so we use ssh on those. But on most of the telnet boxes, the ssh account isn't there.
- 05-11-2010 #4
okay.. so you are looking for script which does something like
Is this assumption correct?status_tel=check- telnet() && status_ssh = check -ssh()
If ( status_tel == "failed" && status_ssh == "failed" )
//ask for new inputs- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-11-2010 #5Just Joined!
- Join Date
- Jul 2009
- Posts
- 24
As far as my knowledge goes for ssh scripting, it looks like it.
- 05-11-2010 #6
okay.
script to check status of ssh
I hope you can write something like this for telnet and use the status of last command.ssh username@hostname "uptime" #run some command
if [ $? -eq 0 ] ;
then
echo "connection okay"
else
echo "connection not okay"
fi
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-11-2010 #7Just Joined!
- Join Date
- Jul 2009
- Posts
- 24
Awesome!! Thanks!!!!
- 05-11-2010 #8
More hints:
1.Hope you have the root user access for all these machines. (total 50 machines)
so create a password less login to all these machines (from machine1 -- you can access machine2,machine3,...machine50 without root password - since you have passwordless login)
if you want to disable the prompt like - while logging in as normal "user".
edit /etc/ssh/ssh_config and set "StrictHostKeyChecking no"
It will eliminate stuff like below:
ssh user@hostname "uptime"
user@hostname's password:- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------


Reply With Quote