Find the answer to your Linux question:
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 ...
  1. #1
    Just 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!!

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    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
    -------------------

  3. #3
    Just 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.

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    okay.. so you are looking for script which does something like

    status_tel=check- telnet() && status_ssh = check -ssh()

    If ( status_tel == "failed" && status_ssh == "failed" )
    //ask for new inputs
    Is this assumption correct?
    - 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
    -------------------

  5. #5
    Just Joined!
    Join Date
    Jul 2009
    Posts
    24
    As far as my knowledge goes for ssh scripting, it looks like it.

  6. #6
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    okay.
    script to check status of ssh
    ssh username@hostname "uptime" #run some command
    if [ $? -eq 0 ] ;
    then
    echo "connection okay"
    else
    echo "connection not okay"
    fi
    I hope you can write something like this for telnet and use the status of last command.
    - 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
    -------------------

  7. #7
    Just Joined!
    Join Date
    Jul 2009
    Posts
    24
    Awesome!! Thanks!!!!

  8. #8
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    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
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...