Expect scripting telnet stop on bad username or password
I am trying to build and expect script to log into multiple aix boxes and change password. I need for the script to terminate if it cannot log into a server because the username or password is wrong.
Last edited by Franklin52; 10-11-2012 at 05:25 AM..
Reason: Please use code tags for data and code samples
Can we write a script to telnet to a unix server from unix with the username and password hardcoded in the script??
something like ssh a@b -p password ??? (5 Replies)
Somewhat long story:
I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage.
This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Hello to all...this is my first post (so please go easy). :)
I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
I have a real need to telnet into my new Ubuntu 8.10 server and have Googled my eyes out with ideas that don't work. I CAN telnet out of the server, but I CANNOT telnet into it (connection refused error). I have updated my resolv.conf file but its expert time. ANY IDEAS??? THANKS!!! I knew I was... (13 Replies)
I have created a shell script to telnet remote machine. Here is the problem I am not able to pass the login username and password to the telnet session. I have searched forum and got few other methods to achieve this. But I need to know what's wrong in the below script.
username="root"... (2 Replies)
Hi,
I currently have a UNIX script with a function that uses a username and password to connect to the database, retrieve some information and then exit.
At the moment, am getting the username and password from a hidden plain text file and permission set to -r--------, i.e. read only to who... (1 Reply)
Hi
First of all I tried lot of forums to create my first expect script. But I am totally stumped at the last step. I am no Linux Admin or ever trained in Linux. I just tried to create the script logically
History :
I need to to change my password across lot of servers in Linux over ssh
... (4 Replies)
Hi
I am new to using unix and am struggling with a script i am writing. What i am trying to do is get a user to enter a username, check the original file i created with username and pin to see if their is a corresponding entry. Next ask the user to enter the pin and see if this matches... (5 Replies)
Hi
I'm trying to run a script " abc.sh" which triggers "use.sh" .
abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script.
Please find below the scripts:
#abc.sh
#!/usr/bin/expect -f
exec /root/use.sh
expect "*name*"
send... (1 Reply)
Discussion started by: baddykam
1 Replies
LEARN ABOUT CENTOS
libssh2_userauth_password_ex
libssh2_userauth_password_ex(3) libssh2 manual libssh2_userauth_password_ex(3)NAME
libssh2_userauth_password_ex - authenticate a session with username and password
SYNOPSIS
#include <libssh2.h>
int libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
const char *username,
unsigned int username_len,
const char *password,
unsigned int password_len,
LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)));
#define libssh2_userauth_password(session, username, password)
libssh2_userauth_password_ex((session), (username),
strlen(username),
(password), strlen(password), NULL)
DESCRIPTION
session - Session instance as returned by libssh2_session_init_ex(3)
username - Name of user to attempt plain password authentication for.
username_len - Length of username parameter.
password - Password to use for authenticating username.
password_len - Length of password parameter.
passwd_change_cb - If the host accepts authentication but requests that the password be changed, this callback will be issued. If no call-
back is defined, but server required password change, authentication will fail.
Attempt basic password authentication. Note that many SSH servers which appear to support ordinary password authentication actually have it
disabled and use Keyboard Interactive authentication (routed via PAM or another authentication backed) instead.
RETURN VALUE
Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a
negative number, it isn't really a failure per se.
ERRORS
Some of the errors this function may return include:
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed.
LIBSSH2_ERROR_SOCKET_SEND - Unable to send data on socket.
LIBSSH2_ERROR_PASSWORD_EXPIRED -
IBSSH2_ERROR_AUTHENTICATION_FAILED - failed, invalid username/password or public/private key.
SEE ALSO libssh2_session_init_ex(3)libssh2 0.15 1 Jun 2007 libssh2_userauth_password_ex(3)