Expect Script to Automate SSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect Script to Automate SSH
# 1  
Old 08-03-2010
Expect Script to Automate SSH

How would I write an expect script to automate ssh and what file extention do expect files use?
# 2  
Old 08-06-2010
bump.
# 3  
Old 08-06-2010
Bad bump.

Question unclear (hence no replies). Please rephrase.

Are you asking about expect, or ssh? And what file extensions?
# 4  
Old 08-06-2010
Actually my question seems completely straightforward...

I would like to know how to write a script using expect that would automate an ssh command.

Something like a script that knows a username, password, and ip address-- I run the script, and it logs me into a linux box

-------------------------------------------------------------------------------
-------------------------------------------------------------------------------------

As for file extentions, that's also very straightforward...

I'm wondering what the file extention is for an expect script file. Similar to how the extension to a shell script file is .sh, or a text file is .txt
# 5  
Old 08-06-2010
expect can use any name/file extension.. I give them .exp.

Is there are a reason you cannot use ssh keys? expect will do whatever you want... but ssh/bash/ksh or whatever shell is probably way more easy to work iwth.
# 6  
Old 08-06-2010
I need the script to ssh into a switch and change some values, so I'm thinking expect is my best option to accomplish that.
# 7  
Old 08-06-2010
Forgive us for being a bit jaded; this place is barraged with folks brute-forcing plaintext passwords into ssh for no good reason, to the that point I've got a template prepared to answer them. A blackbox that can't use keys is a good reason. Sorry.

Here, have the first google hit for "how to use expect". A nice, simple general illustration of the process.

Keep in mind that passwords passed along the commandline are visible to anyone on the system for the entire duration of the process they were passed to. best to either hardcode it or pipe it into stdin or some such.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automate OTPW login to ssh via bash script

Hello everyone. I'm a Linux novice trying out a lot of bash scripting lately, as it is so very addictive. Lately I have been setting up one of my boxes remotely and have been hardening it as much as possible. Please allow me to explain the scenario, as it does tend to become a little... (1 Reply)
Discussion started by: instro
1 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Shell Programming and Scripting

Unable to automate SSH in Script

Hi I have a script at Server B. I want to run it from server A via another script. I tried the following command. ssh mss@247.123.456.123 "sh pm10.sh" It's getting login automatically, but while running the script through error like "reppar: command not found" where reppar is an application... (4 Replies)
Discussion started by: rajeshmepco
4 Replies

4. Shell Programming and Scripting

How to automate SSH remote connection with a shell script

Hi Guys! I am trying to write a shell script for automated ssh. vairable user and passwd have initialized correctly, but when I use the following it still prompting me for the password. #!/usr/bin/bash user='root@10.14.76.225' passwd='admin' ssh $user $passwd uptime exit I... (3 Replies)
Discussion started by: pinpe
3 Replies

5. Shell Programming and Scripting

Script using SSH with expect command

Hi all, I want to connect to some host with "ssh". I have googled and got some commands of "expect" and "spawn". I was not aware of these commands and tried below script. $ cat auto.sh set host xx.xx.xx.xx set password abcd@1234 set user root spawn ssh $user@$host expect "*?assword:*"... (4 Replies)
Discussion started by: divya bandipotu
4 Replies

6. Shell Programming and Scripting

Using expect to automate sftp

I am trying to use a for loop in my expect cmdFile that I am calling. I want to be able to call either one file name or a series of file names in the working directory (that I won't know the names before hand) and then pass the names to the sftp program. Something like for i in (ls *txt) do (0 Replies)
Discussion started by: vedder191
0 Replies

7. Shell Programming and Scripting

Expect script to automate telnet session

Hi all, I am currently running a daemon which creates a virtual terminal for testing purposes. Essentially, if I were to interact with it manually, this is what I get. john@test1:~$telnet localhost 7777 Trying ::1... Connected to localhost. Escape character is '^]' mip6d> pl eth2... (6 Replies)
Discussion started by: abxccd
6 Replies

8. Shell Programming and Scripting

How to automate sftp without using expect script?

How to automate sftp with out using expect script? My batch file has the password but it is not taking. Please see below. I want to use this sftp connection in a loop for pushing new files in a directory one at a time. Hence I can not use an expect script. bash-2.05$... (5 Replies)
Discussion started by: Tuxidow
5 Replies

9. Shell Programming and Scripting

SSH Expect Script

Ok, i don't know if anyone else here have had to deal with something like this before, but here's my situation. I have about 1000+ servers I need to log into to do something. What i need to do is to log into each server, go to a certain directory on each of the servers, copy the files that... (3 Replies)
Discussion started by: SkySmart
3 Replies

10. Shell Programming and Scripting

Expect script to ssh into MMI

Guys, I know this is tricky.. I'm trying to write a script to pull info from a MMI device. Following script logins into the server and then changes to super user. Opens MMI session and then exits out. I need to run the command under the MMI session "dsp_alarm_span all" Is there any other way to... (2 Replies)
Discussion started by: miltonrods
2 Replies
Login or Register to Ask a Question