Thread: How do I automate this in bash?

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    How do I automate this in bash?

    I'm trying to find a way to do this in a bash script instead of manually typing 'yes' when ssh asks:
    Code:
    $ ssh `hostname` # enter "yes"
    $ exit
    $ ssh localhost # enter "yes"
    $ exit
    I tried this, but it didn't work:
    Code:
    echo "yes\nexit\n" > $(ssh `hostname`)
    It still waits here for me to type something:
    Code:
    The authenticity of host 'myhost (10.1.2.3)' can't be established.
    RSA key fingerprint is 32:5d:aa:67:1f:76:bb:68:dd:d2:79:39:cc:21:ee:e0.
    Are you sure you want to continue connecting (yes/no)?
    Any ideas?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  2. #2
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Thanks, that worked perfectly.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Why not just add -o StrictHostKeyChecking=no to the command line?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by brewbuck View Post
    Why not just add -o StrictHostKeyChecking=no to the command line?
    I don't know much about ssh options, but I don't think that will add the host to the known_hosts file which is what I need to do.
    I need to make it so that when some other programs do "ssh `hostname`" they won't get prompted to enter yes/no.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Limiting the scope of a function in bash.
    By Kennedy in forum Tech Board
    Replies: 3
    Last Post: 06-24-2010, 12:08 PM
  2. background jobs running inside a bash script
    By lehe in forum Linux Programming
    Replies: 8
    Last Post: 08-02-2009, 04:40 PM
  3. Replies: 3
    Last Post: 04-10-2009, 12:57 AM
  4. bash scripting?
    By Draco in forum Linux Programming
    Replies: 1
    Last Post: 01-08-2007, 06:15 AM
  5. redirecting standard error in Bash
    By wozza in forum Linux Programming
    Replies: 3
    Last Post: 07-16-2002, 04:55 AM