Doing ssh to a server for the first time. spawn ssh user@ip
expect { "yes/no)?" {
send "yes\r"}
"password:" {
send "password\r"}
}
if doing ssh for the second time and ssh key has changed then we can write a script to delete the line in known_host which contains the key and then ssh.
My first question is do we get any popup if trying to run the script on linux box? If yes how can a tcl script handle that?
When running the same script on windows we get a popup. How can we handle that popup from the script itself?
On Wednesday, June 20, 2012 1:12:55 AM UTC-6, Saurabh wrote:
> My first question is do we get any popup if trying to run the script on linux box? If yes how can a tcl script handle that?
This will depend on what is actually running when you call shh; if you're running openssh, then you can add -oStrictHostKeyChecking=no to the command call or add it to your ssh_config file. This will automatically accept add new keys to the known_host file.
http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&sektion=5
> When running the same script on windows we get a popup. How can we handle that popup from the script itself?
Again, this will depend on ssh, but the easiest way would be to mimic the above with the equivalent settings for the windows ssh client.
You could also look in to using twapi to deal with the popup if there's no way to disable it. I haven't used twapi to do this myself...
http://twapi.magicsplat.com
You probably already know this, but for the benefit of anyone who may not... It's generally a bad idea to blindly accept a hosts key, unless the remote server is under your control.
On Thursday, June 21, 2012 2:47:43 AM UTC+5:30, gho...@gmail.com wrote:
> On Wednesday, June 20, 2012 1:12:55 AM UTC-6, Saurabh wrote:
> > My first question is do we get any popup if trying to run the script on linux box? If yes how can a tcl script handle that?
> This will depend on what is actually running when you call shh; if you're running openssh, then you can add -oStrictHostKeyChecking=no to the command call or add it to your ssh_config file. This will automatically accept add new keys to the known_host file.
> http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&sektion=5
> > When running the same script on windows we get a popup. How can we handle that popup from the script itself?
> Again, this will depend on ssh, but the easiest way would be to mimic the above with the equivalent settings for the windows ssh client.
> You could also look in to using twapi to deal with the popup if there's no way to disable it. I haven't used twapi to do this myself...
> http://twapi.magicsplat.com
> You probably already know this, but for the benefit of anyone who may not... It's generally a bad idea to blindly accept a hosts key, unless the remote server is under your control.
If you are running this on a linux server, there is high possibility that you will not get a popup window (since you will be using a CLI client). Though you might get a prompt on the CLI itself.
I think that would be easy to handle using Expect.
In case you get a popup window (on windows or linux), you simply cannot use Expect to handle it. So you would need some gui automation tool to handle it. On windows, you can code it yourself using TWAPI. Not sure about linux
On Saturday, June 23, 2012 10:53:30 PM UTC+5:30, Saurabh wrote:
> On Thursday, June 21, 2012 2:47:43 AM UTC+5:30, gho...@gmail.com wrote:
> > On Wednesday, June 20, 2012 1:12:55 AM UTC-6, Saurabh wrote:
> > > My first question is do we get any popup if trying to run the script on linux box? If yes how can a tcl script handle that?
> > This will depend on what is actually running when you call shh; if you're running openssh, then you can add -oStrictHostKeyChecking=no to the command call or add it to your ssh_config file. This will automatically accept add new keys to the known_host file.
> > http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&sektion=5
> > > When running the same script on windows we get a popup. How can we handle that popup from the script itself?
> > Again, this will depend on ssh, but the easiest way would be to mimic the above with the equivalent settings for the windows ssh client.
> > You could also look in to using twapi to deal with the popup if there's no way to disable it. I haven't used twapi to do this myself...
> > http://twapi.magicsplat.com
> > You probably already know this, but for the benefit of anyone who may not... It's generally a bad idea to blindly accept a hosts key, unless the remote server is under your control.