I have a question about ppp. Our network uses secureid cards and
requires that I input a pin and 6 digits prior to the login sequence.
What is the easiest solution for a login script for ppp?
Thanks in advance
Jim
I have a question about ppp. Our network uses secureid cards and
requires that I input a pin and 6 digits prior to the login sequence.
What is the easiest solution for a login script for ppp?
Thanks in advance
Jim
Use something like:
pppd modem lock crtscts connect \
"chat -v '' ATDT5551212 CONNECT \d\dpin123456 \
login: account assword: password" /dev/ttyS1 38400
(If you don't press the return after the pin and six numbers, then
append the \c modifier to the end of the number sequence.)
If you don't like chat, you may use dip. If you don't like dip, you
may use tcl. The pppd process does not care how you establish the link
and get the remote ppp software to start.
--
I have the same situation with my dialin at work. I wrote a pair of perlQuote:>I have a question about ppp. Our network uses secureid cards and
>requires that I input a pin and 6 digits prior to the login sequence.
>What is the easiest solution for a login script for ppp?
Yeah, it's probably way overblown, but it works! And mind you, it's
hardcoded for my system and there's precious little in the way of error
checking. Can you say, "Quick and dirty?" I knew you could!
Here are the scripts. You'll see a call to &readline() in there. I
hacked my version of perl to support the GNU Readline package. (No, you
can't have my patches. Don't ask. I lost the sources when I "neatened"
a directory tree...) Anyway, just replace the call to &readline() with
anything that'll read STDIN.
---=== Beginning of 'pppstart' ===---
#! /usr/bin/perl
if ($pid = fork) {
# Parent -- Keep the tty so we can ask for
# the passcode
$AF_INET = 2;
$SOCK_STREAM = 1;
$sockaddr = 'S n a4 x8';
$port = 1111;
($name, $aliases, $proto) = getprotobyname('tcp');
$this = pack($sockaddr, $AF_INET, $port, "\0\0\0\0");
socket(S,$AF_INET,$SOCK_STREAM,$proto) || die "Can't make socket: $!";
bind(S,$this) || die "Can't bind: $!";
listen(S,5) || die "Can't listen: $!";
select(NS); $| = 1;
select(S); $| = 1;
select(STDOUT);
print "Dialing Motorola...\n";
$addr = accept(NS,S) || die "Accept: $!";
$passcode = &readline("Enter Passcode: ");
print NS "$passcode\n";
close(NS);
close(S);
exit;
elsif (defined $pid) {Quote:}
$link = "/etc/resolv.conf";
$real = "/etc/resolv.conf-mot";
"connect", "/usr/local/sbin/plchat",
"domain", "cig.mot.com"
);
unlink($link);
symlink($real,$link);
else {Quote:}
---=== End of 'pppstart' ===---Quote:}
---=== Beginning of 'plchat' ===---
#! /usr/bin/perl
$/ = "\r";
print "ATZ1\r";
$_ = <> until (/OK/i);
print "ATDTxxxxxxx\r"; # Phone number goes here!
$_ = <> until (/CONNECT/i);
$_ .= getc() until (/Username$/i);
print "king\r";
$_ .= getc() until (/PASSCODE$/i);
print &passcode . "\r";
$_ .= getc() until (/Command$/i);
print "ppp\r";
exit;
sub passcode {
$AF_INET = 2;
$SOCK_STREAM = 1;
$sockaddr = 'S n a4 x8';
$port = 1111;
$hostname = "localhost";
($name, $aliases, $proto) = getprotobyname('tcp');
($name,$aliases,$type,$len,$addr) = gethostbyname($hostname);
socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
connect(S,pack($sockaddr,$AF_INET,$port,$addr)) || die "connect: $!";
select(S); $| = 1; select(STDOUT);
chop($passcode = <S>);
close(S);
return $passcode;
---=== End of 'plchat' ===---Quote:}
1. Got interactive ppp login to work finally
I requested help awhile back on an interactive ppp login. Where I work
they ask for a passcode that changes every 30 seconds. I looked at all
the mail I got and ended up writing an expect script to start pppd.
The following is the script.
Thanks for all who responded.
Jim
#!/usr/local/bin/expect -f
send_user "Hello, starting ppp\n"
set user USERNAMEHERE
set password PASSWORDHERE
set modem /dev/cua1
set dialup 5551212
send_user "Passcode: "
set timeout 60
expect_user -re "(.*)\n"
set passcode $expect_out(1,string)
spawn -noecho -open [open $modem "r+"]
send "ATDT $dialup\r"
set timeout 60
set counter 0
expect {
-re "CONNECT" {
send "\r"
continue -expect
}
-re ".*NO CAR.*" {
send_user "No Carrier"
exit
}
-re ".*ter Pass.*: " {
send "$passcode\r"
continue -expect
}
-re "Your.*" {
send "\r"
continue -expect
}
-re "login: " {
send "$user\r"
continue -expect
}
-re "Password:"
{send "$password\r"}
timeout {
send "\r"
incr counter
if { $counter > 5 } {
send_user "Cannot Connect\n"
exit
}
else {
continue -expect
}
}
#put your ip address here XXX.XXX.XXX.XXX
overlay -0 $spawn_id -1 $spawn_id -2 $spawn_id pppd /dev/cua1 19200 \
XXX.XXX.XXX.XXX: crtscts modem defaultroute
5. Problem - testing for interactive vs. non-interactive using tcsh/prompt
6. More Lies from a Linux "advocate"
7. Problem in number of interactive user login to a NIS+ replica server
8. ? about solaris being messy in terms of devices
9. Install interactive package non-interactive during Jumpstart
10. Checking for interactive login
11. interactive vs not-interactive shell
12. bash - login vs interactive startup scripts
13. Login failure for non-interactive dialups