What does expect mean? Information and translations of expect in the most comprehensive dictionary definitions resource on the web. I have modified the script to work with SSH, as I do not use Telnet on my router. The program that follows was built in Debian,it is a simple demonstration on how to use the library. Also, SSH in the Cygwin environment is nearly identical to the way it is used on Unix, allowing me to use xterm and ssh instead of PuTTY, a fine SSH/terminal standalone application. What would I need to do to have the expect script connect to each of these IP addresses and perform the rest of the tasks in the script as well? Here is the Expect script I have so far: #!/usr/bin/expect -f #Tells interpreter where the expect program is located. Lee Eakin has ported the kibitz script from Tcl/Expect to Perl/Expect. I have never even looked at an expect script before, and this made it easy to understand what is going on. This tutorial shows how the Expect package can be used within a Tcl command-line script to log on to a remote machine via Telnet or SSH and return the contents of the current working directory. For a work around I used perl and a perl module called Net::SSH::Expect. Sure Dell\Sonicwall offer you the option of buying there automatic GM something or other but that’s rather expensive if you just want a central back for all your config files. Ssh to the remote site for the first time will trigger this:. [if you know about Expect, you can jump your interested area] Introduction In wikipedia, about expect "Expect is a Unix automation and testing tool, written by Don Libes as an extension to the Tcl scripting language, for interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others. The following example, although extremely simple, provides a useful introduction to creating and using shell scripts. ssh-agent - Single Sign-On using SSH. activestate expect which I believe you already do write your script and save it as a. A few years ago I was supporting a very diverse environment with Solaris, AIX, and Linux servers; some with password logins, public/private key authentication, and several with SecurID passwords. Limit your SSH logins using GeoLite2 Country 2 Mar 2019 in Networking, Security & Encryption, System. Specifically the StrictHostKeysChecking m. exp extension. I often have to log into servers to pull information, add a user, etc… These tasks are hard to script from a local machine because of the way SSH shell access works (creating a new shell instance when logging into remote server). I have ssh expect script using to login cisco devices called be another cgi-script. 4 or later installed on your machine. SSH Key Exchange Error - fix by repairing the key cache. 200 ls -l /tmp. #!/usr/bin/expect #Start SSH session spawn ssh [email protected]_controller sleep 2. My Shell script works fine if I run it as standalone. While checking for a script which checks for a username ssh login with password to a remote ssh host, either windows machine with openssh or a linux machine. cz) Expect script which can execute commands on multiple servers via SSH Vložil/a cm3l1k1 [1], 21 Září, 2011 - 10:14 GNU/Linux a BSD [2] Programming [3]. If you want to change it to yours, then modify it directly in the script. A common use of Expects scripts is to automate SSH sessions between a local computer and a remote server. NET is client library to connect to SSH servers written in C# with multitasking support. This script allows a network administrator to send Cisco commands on a number of selected remote devices (router, firewall, switch, Wireless Access Points ), via SSH or Telnet (the script automatically handles both types of connection). Presently the only way I can acquire the output from the "Expect" script is to not use the Perl module "Expect", here is the working script:. Use the API to build components based on SSH Connection Manager. Pay attention to the syntax. 1" PORT="22" USER="admin" PASS="123456" TMP=$(mktemp) TODAY=$(date +%F) FILENAME="$HOSTNAME-$TODAY" PATH. How to get exit code of spawned process? expect. Thanks Al [email protected] Another common way to run commands on remote servers as root is to use the su – root command, where sudo is not configured. The scp_kopy script copies (via “spawn scp”) a file across to the other device. These tags are not case sensitive, but the order in which they are specified must be precise, as described in the following list: Command: This is the first entry in the SSH Connector script. C-Kermit is a combined network and serial communication software package offering a consistent, transport-independent, cross-platform approach to connection establishment, terminal sessions, file transfer, file management, character-set translation, numeric and alphanumeric paging, and automation of file transfer and management, dialogs, and communication tasks through its built-in scripting. They are similar to shell scripts but utilize the. org) sources. Below is a sample expect script to handle ssh password prompt should you not get the ssh keys to be working between hosts: #!/usr/bin/expect -f set host XXX set user XXX. SSH::OpenSSH::Parallel is an advanced scheduler that allows one to run commands in remote hosts in parallel. #!/usr/bin/expect --spawn /usr/bin/scp [email protected] What does expect mean? Information and translations of expect in the most comprehensive dictionary definitions resource on the web. Lee Eakin has ported the kibitz script from Tcl/Expect to Perl/Expect. Expect is known primarily as an indispensable application for system administrators. Jeff Carr provided a simple example of how handle terminal window resize events (transmitted via the WINCH signal) in a ssh session. ls the current folder. The first step, similar to writing a bash script, is to tell the script what it's executing under. Expect is a scripting language used to automate interactive shells. 1 makes this task more standard. It uses Unix pseudo terminals to wrap up subprocesses transparently, allowing the automation of arbitrary applications that are. Can anybody let me know how to execute sudo commands with expect? I tried the following but this is not working. Listed below are a couple of Expect Scripts which can be used to create or edit your own scripts for DX Scriptable Health Checking. 1 success the pblm,i want the script not to ask anything from user. SSHPASS VS EXPECT, what to expect when you are expecting? Some time ago I was in a middle of a script and I found myself trying to connect to a SFTP server to download some files. It can be achieved by using 'expect' command provided by the tcl shell. Introduction to Groovy/Expect Text-Based Interaction. SSH Using Expect Automation Scripting In Linux By Passing Password From Script - Duration: Expect Script using SED to edit /etc/hosts in a cluster | Expect Scripting Tutorial - Duration:. This is where Parallel SSH or PSSH tool comes in handy, is a python based application, which allows you to execute commands on multiple hosts in parallel at the same time. Use SSH and SCP to Manage Lots of Linux Machines. Expect Scripting gnulamp. From what I understand you are basically trying to tell the script what to 'expect' after issuing each command. I am TCL newbie and I thought I had copied all the best code on the Internet but it is not working for me Writing an expect script to ssh into a list of servers and do some stuff. I'm trying to create a script to restart pfSense, but I am stuck on the command to do so. Execute script. #conf t #ip name-server 10. i heard this is possible by expect cmd. You can find both scripts in the examples/ subdir. Provide SSH password inside a script. First of all, Thank you for this script. txt) or read online for free. While checking for a script which checks for a username ssh login with password to a remote ssh host, either windows machine with openssh or a linux machine. Script create SSH connection to every server located in hosts file, store fingerprint as trusted if needed, make "sudo su -" and push commands. This is where Parallel SSH or PSSH tool comes in handy, is a python based application, which allows you to execute commands on multiple hosts in parallel at the same time. Also, it pauses for several se. com once more. SSH client software that is installed on your Linux or macOS operating system by default. expect-lite scripts use special character(s) at the beginning of each line to indicate the action. The following code is a Linux Expect script which will: Log into an A10 Networks Thunder system via SSH; Enter the Configuration mode. Line 2 is too late to decide to use /usr/bin/expect as an interpreter instead. Testing SSH agent forwarding. Expect is a Unix and Linux automation and testing tool. If you are not using SSH keys, you will be prompted a password, and will need to enter it manually. 1 success the pblm,i want the script not to ask anything from user. and do what you'd normally do. Using an Expect SSH script to automate configuration on a Cisco device is easy. tcl this will execute your script P. sourceforge. Linux Automatic SSH tunnel script Last updated by Shayne M on May 22, 2013 10:29 If you want to automate the login process so you can establish a tunnel as part of a script, or on startup you can create a small script to fill in your password automatically using the "expect" scripting language. in linux machine i am running some process refelct: for getting the process id of all the reflect processes i m using. Configuration of SSH access for use by remote shell scripts and remote tools for maintenance, remote backup, and archival systems has great usefulness, but it has always been at the very least a subject of high controversy when it comes to server security. Post by jstechg » Thu Jul 26, 2018 8:39 pm I need to connect from a machine with Centos 7 to a switch using ssh and in the same execute the command "sh vlan 110". Paramiko Expect provides an expect-like extension for the Paramiko SSH library which allows scripts to fully interact with hosts via a true SSH connection. tcl file go to the directory where your script is stored in the command prompt C:\usr\bin\path to your script>tclsh scriptname. txt is very simple: S command E[delay] expected_text. This script will help Linux administrators in tasks where they need push commands on multiple servers in network. Expect Script SSH Example. The expect module is designed for simple scenarios. The class is constructed with an SSH Client object (this will likely be extended to support a transport in future for more flexibility). The reasons to do this are fairly advanced and beyond the scope of this post. Make script executable and run it on remote server as. Expect Scripting gnulamp. Post by jstechg » Thu Jul 26, 2018 8:39 pm I need to connect from a machine with Centos 7 to a switch using ssh and in the same execute the command "sh vlan 110". Known issues. I'm trying to write a script using expect. The expect-lite language […]. Public key authentication allows you to login to a remote host via the SSH protocol without a password and is more secure than password-based authentication. Expect "talks" to other interactive programs according to a script. yum install expect tcl -y Use auto login ssh script. ssh into the machine. Introduction to Groovy/Expect Text-Based Interaction. If it is actually spawning ssh properly and then ssh runs but can't connect or something else, then try expecting. Script is now completed, so that's good. But you can have AppleScript prompt for the password, then pass it to an expect script as part of the "do shell script" command line. Once confirmed, the host key will be added to ~/. Below is a sample expect script to handle ssh password prompt should you not get the ssh keys to be working between hosts: #!/usr/bin/expect -f set host XXX set user XXX. We’ve shown you how to use SSH to transfer files securely. Thanks to both! Historical notes:. For the expect utility to work we need to install the "expect" package. pm, I try to ssh to a computer and do "ls" (a simple command now, more commands later). script text, program logic, etc. 100) and SSH Command is the command you want to execute. txt) or read online for free. Your script starts off being run by whatever shell you are already in. Use the API to build components based on SSH Connection Manager. For various reasons you might want to execute commands via SSH, using PowerShell. 200 ls -l /tmp. For example, you could connect to a dozen different machines and reboot them all at once. Both scripts have been thoroughly used and tested only with Cisco routers and switches. This is available in Ubuntu/Debian repos and you don't have to deal with integrating expect with bash. I am trying to write scripts but I cannot open SSH session for the swtichs from my unix terminal. Setup Your Script. When you run ssh on the remote computer to log into an other server, the login can happen using the ssh agent on your local computer (laptop) using the key on your local computer. 0, 24 February 2000. However, it relies on the "Expect" Linux. If you also still are using rsh, the SSH. Also to keep as a code snippet for future work-related scripts. I do not need to interact, do not need to fire any command on each server, I just want to do an ssh and come out, with a return code mentioning whether it was successful or not. SSH Connection Manager is SSIS Connection Manager for establishing SSH connections. Running remote command over ssh with Groovy This post is for those who are searching for how to run a remote command over ssh through a groovy script. "Failed to connect. Below we have an example "expect" script that will connect to a single host with a non-privileged account, enter a password, run sudo command, enter the password again, execute the "userdel" command as root, and log out. root shell : The password can be brute-forced remotely. In my examples I’ll use this method to create an expect script, I’ll put comments to describe how the actions/commands are implemented. Expect scripting generally works on specified strings. For various reasons you might want to execute commands via SSH, using PowerShell. Install expect. I want to enable after I connect to the router through ssh before I execute the rest of my commands in command. Be careful how you use this script, e. Some just show a notice to use the "service" command. pdf), Text File (. recently I have moved my script to UCS server running RedHut Linux and I have a problem. Expect scripting generally works on specified strings. The script clears the monitor screen of all previous lines and then writes the text Good morning, world. Let's look at the situation when you need to pick up some files from a remote host with authorization by public key. Appreciate if anybody can share ideas or working scripts. Your script starts off being run by whatever shell you are already in. expect([ssh. in a shell script, the best way to make ssh non-interactive usually is a public-key authentication. Log in with a private key. This may need adjusting according to #your specific environment. How do I run a command using ssh under UNIX, OS X, *BSD, and Linux operating systems? The SSH client program can be used for logging into a remote machine or server and for executing commands on a remote machine. What would I need to do to have the expect script connect to each of these IP addresses and perform the rest of the tasks in the script as well? Here is the Expect script I have so far: #!/usr/bin/expect -f #Tells interpreter where the expect program is located. I used a Linux based system and the "expect" scripting language. Expect scripting language is used to feed input automatically to an interactive program. Note: To run this script, you must have ActiveState Expect for Windows and ActiveTcl 8. Running remote command over ssh with Groovy This post is for those who are searching for how to run a remote command over ssh through a groovy script. Paramiko Expect provides an expect-like extension for the Paramiko SSH library which allows scripts to fully interact with hosts via a true SSH connection. Discover more freelance jobs online on PeoplePerHour!. If it is actually spawning ssh properly and then ssh runs but can't connect or something else, then try expecting. If you are using Debian Linux then use apt-get as follows : # apt-get install expect # apt-get install expectk. the Expect home page Don Libes papers, written in the early days of Expect, are also interesting and educational. You may set any options you wish in here, however doing so will require you to post extra information that you may not want to if you run into issues. Provide SSH password inside a script. Can anyone help me in creating an expect script to just do an SSH on a list of servers and check if it was fine. Expect is a command line tool built into Unix systems. When we use pexpect to automate the manual process, we take a look at what we expect to happen. SSH (Secure Shell) is a protocol to log into another computer over a network, to execute commands in a remote machine, and to move files from one machine to another. Send command via ssh script Someone knows how to run an ssh command script to the device? I need to execute that script if and interface get down or something like that, the trigger is a monitoring software. , but variable names, handler names and static text can still be extracted. scp stands for secure cp (copy), which means you can copy files across ssh connection. Expect script which can execute commands on multiple servers via SSH Publikováno na serveru Security-Portal. This script allows a network administrator to send Cisco commands on a number of selected remote devices (router, firewall, switch, Wireless Access Points ), via SSH or Telnet (the script automatically handles both types of connection). Be careful how you use this script, e. I have ssh expect script using to login cisco devices called be another cgi-script. Here is my code: import sys import os from subprocess import Popen, PIPE, STDOUT from time import sleep from os import waitpid, execv, read, write #Ports are handled in. txt) or read online for free. exp, and paste the following content, after that make it executable with the command. An interactive shell reads commands from user input on a tty. Regarding scripting ssh via Expect: Your point is basically valid (and is probably true for the OP), but there are cases where I do this - use Expect as a wrapper around ssh. I have found that the comments in the configuration break the script with the version of Expect on OS X. First of all I tried the powerful 'wget' but this program does not support ssh connections. Alter the cmd to change the ssh client used, or to prepend it with network. For expect we use the following: #!/usr/bin/expect You also must place interact at the end, so your script looks like this: #!/usr/bin. The script can be customized for other network and security systems including Cisco, Juniper, etc. for long time I have used and working perfectly running on Solaris server. sh to install all dependencies on a. The cool thing is that the expect command can be told to expect different outputs and execute depending on which of them is received. expect "Password: " send "password\n" interact Save the file as filename. bin installer runs fine, but with below message:. Interactive connections like this are not the main point of Plink. Here is a little trick showing you how to do it. Script create SSH connection to every server located in hosts file, store fingerprint as trusted if needed, make "sudo su -" and push commands. Thanks Al [email protected] Expect can help you to automate interactive console applications. 3p1) qui se connecte au serveur Windows 2000 (OpenSSH. So recently I have been working on a small script that will login to a remote unix host and change its password, I've never had much experience with expect so its been an upward learning curve. spawn to specialize setting up SSH connections. Sure Dell\Sonicwall offer you the option of buying there automatic GM something or other but that’s rather expensive if you just want a central back for all your config files. Say Thanks. As a result I need to call special attention to some fantastic privilege escalation scripts at pentest monkey and rebootuser which I’d highly recommend. 3_Installation_and_Administration_Guide. Be careful how you use this script, e. The easiest way is to use sshpass. If your script hangs and doesn't continue, try the command. The scripts are collected in one self-extracting EXE file, which you can download by clicking on the link below. There are few tools comes in. There are three situation while accessing ssh: 1. So I wrote this little script that would automatically add my ssh keys to the list of servers. The expect script as expect will automate ssh login, and check for /var/crash (dump) space on the server, and return | The UNIX and Linux Forums. An interpreted language provides branching and high-level control structures to direct the dialogue. Expect-lite is a wrapper for expect designed to allow you to capture an interactive session more directly mapped into a script. VR-Mgmt = 0, VR-Default=2 Try running the CLI command: run script cli2json. exp extension. # Automatize your remote logins through ssh You need **expect** scripting language to run this task. Recently took a new role for work that involved being handed a large number of new Linux servers that I have never logged into before. Create a new file, for example ssh. From what I understand you are basically trying to tell the script what to 'expect' after issuing each command. Known issues. Testing SSH agent forwarding. Paramiko Expect provides an expect-like extension for the Paramiko SSH library which allows scripts to fully interact with hosts via a true SSH connection. » SSH Agent Forwarding Some provisioning requires connecting to remote SSH servers from within the packer instance. Say Thanks. Expect is a UNIX scripting and testing utility which can be used with SSH-based applications, like the Oracle VM CLI. Expect reads cmdfile for a list of commands to execute. Net::SSH::Perl has built-in support for the authentication protocols, so there's no longer any hassle of communicating with any external processes. Be careful how you use this script, e. The response from each host is collected and printed. You are advised to check it on a testing server before you finally do it on a production server. That will show you exactly what expect is looking to match, and should hopefully tell you what is wrong in your. in linux machine i am running some process refelct: for getting the process id of all the reflect processes i m using. But for me the requirement was only to test the. You may set any options you wish in here, however doing so will require you to post extra information that you may not want to if you run into issues. Hi all, i would like to write a script which takes 20 ipaddress in a i/p file and checks for the ssh login of those filesthe o/p should like Ip status 9. Does anyone have an example script that can log into a 3800 switch and perform a "show vlan" and the log off? I have been working with examples from a google search but no luck. I'm trying to create a script to restart pfSense, but I am stuck on the command to do so. By Mayank Sharma – Posted on Nov 6, 2013 Mar 3, 2017 in Linux. 1 – Login with ssh to a remote server and give 1 command there with Expect. In the world of Cloud Servers and Virtual Machines scripting and automation are top priority for any sysadmin. That avoids having a password hardcoded in either the AppleScript or the expect script. Recently took a new role for work that involved being handed a large number of new Linux servers that I have never logged into before. If it is actually spawning ssh properly and then ssh runs but can't connect or something else, then try expecting. Hey sorry for late response. Coupled with autoexpect as we saw above, we can easily automate. Ask Question Asked 7 years, 1 month ago. However, in a controlled environment where the authenticity of ssh hosts is already known, you may want to automatically accept a new host key without checking. To streamline this process, I created a script in Python3 using Paramiko for SSH. Automating Nagios service checks via SSH Expect script. For expect we use the following: #!/usr/bin/expect You also must place interact at the end, so your script looks like this: #!/usr/bin. Expect is a program that "talks" to other interactive programs according to a script. I am trying to write scripts but I cannot open SSH session for the swtichs from my unix terminal. #!/bin/bash BACKUP_DIR="/var/backups" HOSTNAME="192. exp and give it this code: #!/usr/bin/expect eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no [email protected] If you are using Debian Linux then use apt-get as follows : # apt-get install expect # apt-get install expectk. 4 or later installed on your machine. Por convención, Expect utiliza la extensión. Linux SSH - Automation with Send & Expect Scripts By Ken Hess Expect is a natural and intuitive automation scripting language that operates in much the same way humans do when interacting with a system. Scripting backups Is it possible to run forti commands from a batch file on a remote computer? than expect script is easy to execute. Code: #!/bin/expect # Get the list of hosts, one per line ##### set f [open &q Problems with an Expect script SSH into multiple hosts in a loop. You are advised to check it on a testing server before you finally do it on a production server. The expect script is at the bottom of the script below. Let us create a simple shell script with following contents and name it as system-info. Since the Firewall requires interactive mode only, I need to use an Expect script or Net::SSH:Expect I think. I'm new to perl and facing a problem I'm using a perl expect script to login to multiple machines (having same username and password) and execute the date command, initially i tested on one machine, it worked finebut when i use a foreach loop to test the same. Using expect script sysadmins and developers can automate redundant tasks easily. How to get exit code of spawned process? expect. Expect to the rescue! Expect is a nifty program that automates tasks based on input and output. That avoids having a password hardcoded in either the AppleScript or the expect script. Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. but I have to invoke it from ANT. Also, it pauses for several se. Here is a little trick showing you how to do it. Do the following: copy the contents of the script to /usr/local/bin/ssh (or anywhere as long as it’s on your PATH) now when you issue an ssh command in the terminal the script captures the hostname of the machine that you are trying to connect to. It doesn’t matter if the. Can anybody let me know how to execute sudo commands with expect? I tried the following but this is not working. The script can be customized for other network and security systems including Cisco, Juniper, etc. I have successfully created a telnet / ssh script by using putty - but are having some problems creating a expect sequense. Bash script to auto-input password. Does this require to define a time out for the ssh command so that if the prompt is back before this defined time the next commands are executed?? (2 Replies). When we use pexpect to automate the manual process, we take a look at what we expect to happen. Follow the instructions in this article to enable SSH for remote management of a Smoke for Mac OS workstation. Here is my script: Import-Module SshShell. You can find both scripts in the examples/ subdir. I have modified the script to work with SSH, as I do not use Telnet on my router. We use expect generally in case where input from user is required , for eg. Interactive and non-interactive shells and scripts. setting the task up to use a dedicated user with a dedicated SSH key pair. expect is a scripting language that enables the mechanisation of interactive sessions such as telnet, ssh or ftp. Expect to the rescue! Expect is a nifty program that automates tasks based on input and output. 0, 19 November 1999. 190\r" I save it as expectcheck and type expectcheck in the command prompt after setting the path. Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. tcl this will execute your script P. exp extension. Here’s how to keep your SSH sessions alive and prevent the SSH timeout: By sending a “null packet” between the client and the server at a specified interval that is smaller than the timeout value, we can avoid SSH timeout. Hi I am trying to SSH into one host after the other in an expect script. Pexpect allows you to wait for certain STDOUT, and reacts back by sending your lines back to the 'shell'. It works by expecting specific strings, and sending or responding. The reasons to do this are fairly advanced and beyond the scope of this post. I want to enable after I connect to the router through ssh before I execute the rest of my commands in command. Since the Firewall requires interactive mode only, I need to use an Expect script or Net::SSH:Expect I think. Expect is a Unix and Linux automation and testing tool. Your script starts off being run by whatever shell you are already in. Meilleure réponse: Voilà un script qui marche bien chez moi dans les mêmes conditions que les tiennes, à savoir un client Linux (OpenSSH_4. Run your script using arguments like this, use your own. 1 success the pblm,i want the script not to ask anything from user. For example, in our script, we can configure the expect command in such a way that if the username prompt is received, then everything goes as planned; however, if a password prompt is first received, we will leave that device and move to the next one. Automate SSH login with expect or sshpass? Archived You can call it form a bash script, but can't use the expect commands directly in the bash script. C-Kermit is a combined network and serial communication software package offering a consistent, transport-independent, cross-platform approach to connection establishment, terminal sessions, file transfer, file management, character-set translation, numeric and alphanumeric paging, and automation of file transfer and management, dialogs, and communication tasks through its built-in scripting. Expect script to change login passwords using SSH. conf controls execution of traditional scripts added manually or with update-rc. My Shell script works fine if I run it as standalone. Hi all I've written a Perl based expect "script" that utilises SSH to connect to a SBC and execute various commands that I want to capture in order to provide monitoring of the appliance. >maybe I need to use a bash or awk script etc that I can use to read >the text file and then call the expect script and then run the >commands? >-----No. Expect scripting generally works on specified strings. Presented here is a module with functions (that work like cmdlets or commands) for running commands via SSH on remote hosts such as Linux or Unix computers, VMware ESX(i) hosts or network equipment such as routers and switches that support SSH. Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. "Failed to connect. I often have to log into servers to pull information, add a user, etc… These tasks are hard to script from a local machine because of the way SSH shell access works (creating a new shell instance when logging into remote server). SSH client software that is installed on your Linux or macOS operating system by default. My suggestion is to invoke ssh directly and just use pexpect. The only caveat is that the password is stored in the expect script. for long time I have used and working perfectly running on Solaris server. That avoids having a password hardcoded in either the AppleScript or the expect script. Thanks!-Ted. hokky, The server can still have a password. Does this require to define a time out for the ssh command so that if the prompt is back before this defined time the next commands are executed?? (2 Replies). The trick to automating su operations using expect is to launch the su command with the spawn ssh command. Introduction to Groovy/Expect Text-Based Interaction. i heard this is possible by expect cmd. When you run ssh on the remote computer to log into an other server, the login can happen using the ssh agent on your local computer (laptop) using the key on your local computer. Whenever you need to use scp to copy files, it asks for passwords.