Skip to main content

Posts

Showing posts with the label ssh

Tcl Expect Scripts Auto SSH Logins

Tcl Expect Scripts Auto SSH Logins When automating tasks with shell scripts, you may stumble at points that require user interaction, such as password authentication when checking out an SVN repository. One can handle these events by creating expect scripts. Below is an example script that I put together for SSHing into another computer using a password. Be careful how you use this script, e.g. I dont recommend storing passwords in files on your computer, but asking the user their details at the beginning of your installation script and passing them to this script later isnt a bad idea. #!/usr/bin/expect # Set the time allowed to wait for a given response. SEt to 30 seconds because it can take a while # for machines to respond to an ssh request. set timeout 30000 proc connectToServer { user host password port } { set address $user append address "@" append address $host puts "Connecting to server: $host" spawn ssh $address -p $port expect { {*password: } {...