could not send commands SSH session with Net::SSH::Expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting could not send commands SSH session with Net::SSH::Expect
# 1  
Old 08-28-2009
could not send commands SSH session with Net::SSH::Expect

I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands.

With the putty I can connect to the device and execute the commands without any issues.

Here is the sample script

my $ssh = Net::SSH::Expect->new (
'host' => $host,
'user' => $login,
'password' => $passwd,
'timeout' => 15,
'raw_pty' => 1,
'log_file' => "iloExpect.log",
);
if(!defined($connect=$ssh->login()))
{
print "Login Failed with the Host = $host Login $login and Password $passwd";
}
if($connect !~ /$prompt/i)
{
print "\nCould not get the prompt \n";
exit(1);
}
print "\nSending the command [$cmd]\n";
my $output = $ssh->exec('help');
print "\nOutput [$output]\n";



Thanks in Advance,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh = ssh expect and keep everything not change include parameter postion

I have write a script which contains ssh -p 12345 dcplatform@10.125.42.50 ssh 127.0.0.1 -p 5555 "$CMD" ssh root@$GUEST_IP "$CMD" before I use public key, it works well, now I want to change to "expect", BUT I don't want to change above code and "parameter position" I can post a... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

2. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

3. UNIX for Dummies Questions & Answers

SSH session

I ran a job using SSH and then used screen command followed by space bar. Then I ran the job. But after some hours, the internet connection was lost.This had happened to me before. I used to run the whole job again. Today I came across the fact that I could restart the jobs without having to do it... (2 Replies)
Discussion started by: nellierd
2 Replies

4. Shell Programming and Scripting

Send Remote Commands via SSH with variables

Hi there I found the Command to send commands to other servers like: sv01> ssh user@sv02 'ps -ef' But I cant use Variables from a script i want to execute on another server like: sv01> ssh user@sv02 'cd $SCRIPTHOME' although the variable is set on sv01. How can I run commands on sv02 with... (2 Replies)
Discussion started by: DarkSwiss
2 Replies

5. Shell Programming and Scripting

Bash commands to an 'ssh' within an ssh'

I've struggled to find a solution to this problem from searching so I thought I'd write a post to see what can be done. I'm attempting to connect and run commands on 'server2' but because of security limitations I cannot access it directly. I can however ssh into 'server1' and then into... (7 Replies)
Discussion started by: mcintosh.jamie
7 Replies

6. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

7. Shell Programming and Scripting

Expect, SSH and multiple passed commands

Hey Everyone, I have found this script online that has almost all the features I am looking for. However, I do not know enough expect to debug the problem. http://linuxgazette.net/100/misc/tips/sshtool.expect.txt First, it Traps out after it collects the user's password. I do not know... (0 Replies)
Discussion started by: patchsmyle
0 Replies

8. Shell Programming and Scripting

Make ssh and send commands

Hi, I'm trying to make an SSH into a SGSN node and collect some commands printouts.:confused: I really don't know how this can be done. I think it must be like this: #!/bin/bash ssh user@192.168.88.10 Then I must enter the password, but I don't know how to do it, I tried with: echo... (3 Replies)
Discussion started by: nagomes
3 Replies

9. Shell Programming and Scripting

scripting an ssh session?

I know the root login/password for a machines, and I want to automate some commands like this from each: ssh root@remoteHost1 "tail /var/log/messages" ssh root@remoteHost2 "tail /var/log/messages" ssh root@remoteHost3 "tail /var/log/messages" ssh root@remoteHost4 "tail /var/log/messages" ssh... (2 Replies)
Discussion started by: jjinno
2 Replies

10. UNIX for Dummies Questions & Answers

is it possible to ssh within an ssh session?

i have a home network in which one computer can be sshed into from the internet. inside this ssh session, i cannot ssh into another computer on the internal network (LAN) i get the following error: pseudo-terminal will not be alocated because stdin is not a terminal any suggestions would be... (4 Replies)
Discussion started by: noamkrief
4 Replies
Login or Register to Ask a Question
PAM_SSH(8)						    BSD System Manager's Manual 						PAM_SSH(8)

NAME
pam_ssh -- authentication and session management with SSH private keys DESCRIPTION
The SSH authentication service module for PAM, pam_ssh provides functionality for two PAM categories: authentication and session management. SSH Authentication Module The SSH authentication component verifies the identity of a user by prompting the user for a passphrase and verifying that it can decrypt at least one of the user's SSH login keys using that passphrase. The following options may be passed to the authentication module: debug syslog(3) debugging information at LOG_DEBUG level. use_first_pass If the authentication module is not the first in the stack, and a previous module obtained the user's password, then that password is used to decrypt the user's SSH login keys. If this fails, then the authentication module returns failure without prompting the user for a passphrase. try_first_pass Similar to the use_first_pass option, except that if the previously obtained password fails to decrypt any of the SSH login keys, then the user is prompted for an SSH passphrase. try_first_pass has no effect if pam_ssh is the first module on the stack, or if no previous modules obtained the user's password. allow_blank_passphrase Allow SSH keys with no passphrase. If neither use_first_pass nor try_first_pass is specified, pam_ssh will unconditionally ask for an SSH passphrase. In addition to the above authentication procedure, all standard SSH keys (identity, id_rsa, id_dsa) for which the obtained password matches will be decrypted. SSH Session Management Module The SSH session management component initiates sessions by starting an SSH agent, passing it any SSH login keys it decrypted during the authentication phase, and sets the environment variables accordingly. The SSH session management component terminates the session by killing the previously started SSH agent by sending it a SIGTERM. The following options may be passed to the session management module: debug syslog(3) debugging information at LOG_DEBUG level. INFORMATION LEAKS
Be careful with the using the try_first_pass option when pam_ssh is the first authentication module because it will then leak information about existing users without login keys: such users will not be asked for a specific SSH passphrase, whereas non-existing users and existing users with login keys will be asked for a passphrase. FILES
$HOME/.ssh/identity $HOME/.ssh/id_rsa $HOME/.ssh/id_dsa OpenSSH DSA/RSA keys decrypted by pam_ssh. $HOME/.ssh/login-keys.d/ Location of (possibly symbolic links to) OpenSSH DSA/RSA keys used for authentication and decrypted by pam_ssh. /var/log/auth.log Usual log file for syslog(3) SEE ALSO
ssh-agent(1), syslog(3), pam.conf(5), pam(8). AUTHORS
Andrew J. Korty <ajk@iu.edu> wrote pam_ssh. Dag-Erling Smorgrav wrote the original OpenPAM support code. Mark R V Murray wrote the original version of this manual page. Jens Peter Secher introduced the login-key concept. BSD
November 26, 2001 BSD