Rlogin / RSH / SSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rlogin / RSH / SSH
# 1  
Old 03-13-2011
Rlogin / RSH / SSH

Hello,

I am looking for a connection method in which i can connect to a remote server but I want to have only one chance to connect to the remote server (not to be asked for iuser name and password again).
If I have provided a wrong password then I want the connection to broke and be routed back to the local server.

I.e

rlogin <server name> -l <profile name>
<profile name> password: <User enters a wrong password>
[compat]: 3004-300 You entered an invalid login name or password.
Connection to <server name> closed.
# 2  
Old 03-14-2011
You could do this with an expect script that took user and host as parameters, prompts for password without echo and then invokes rlogin and tries the password.
If it fails then terminate, otherwise wait till login OK message ("Last login:" in this case) and switch to an interactive session:

Code:
#!/usr/bin/expect
##assign the first parameter to address and 2nd to username
set address [lrange $argv 0 0]
set username [lrange $argv 1 1]
 
# Prompt for password (without echo) and store it
stty -echo
send_user -- "Password for $username@$address: "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set pass $expect_out(1,string)
 
#Spawn rlogin
spawn rlogin $username@$address
 
# Process result
expect {
     -re "Last login:" { interact }
     -re "an invalid password" { puts "$expect_out(buffer)";close; exit}
     -re "(p|P)assword:" {send "$pass\r";exp_continue}
     "Connection refused" {puts "Host error -> $expect_out(buffer)";close; exit}
     "Connection closed"  {puts "Host error -> $expect_out(buffer)";close; exit}
     "no address.*" {puts "Host error -> $expect_out(buffer)";close; exit}
     timeout {puts "Timeout error. Is device down or unreachable??";close; exit}
}

This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Deny rsh,tn,or rlogin

Is there a way to deny access to a specific remote login option. example: usera--deny telnet access but keep rsh and rlogin userb--keeps telnet, rsh, and rlogin I'm basically trying to contol the access per services instead of changing the LOGIN REMOTELY(rsh,tn,rlogin) option to yes or no. (12 Replies)
Discussion started by: leemalloy
12 Replies

2. Shell Programming and Scripting

rlogin / ssh login with password

Hello, I need to find a way to connect from server1 to 30 other servers using a single line command in order to run various command from the other 30 servers. I am looking for a single line connection command in which i can provide the server name user name and password and connect to the... (2 Replies)
Discussion started by: LiorAmitai
2 Replies

3. UNIX for Dummies Questions & Answers

SSH version of rlogin (ie without password prompt)

I have 3 Solaris 10 UNIX servers, the shadow and passwd file are all identical and are automatically sync every 5 minutes. A majority of the users do not have CLI access but rather use a menu. I currently have menu options that allows them to rlogin to another server and I need to have the... (1 Reply)
Discussion started by: creedonjm
1 Replies

4. UNIX for Dummies Questions & Answers

RSH/rlogin problem

Hello, When I try and RSH/RLOGIN onto a box with user root, I get the prompt but the username/password combination NEVER work. I have the password up properly on the host machine. Does rsh/rlogin not make use of ./etc/passwd and /etc/shadow? (1 Reply)
Discussion started by: mojoman
1 Replies

5. UNIX for Advanced & Expert Users

RSH or SSH & security

I am wanting to run backups to remote servers ie: A to B's tape drive and B to A's tape drive. Should I use rsh or ssh? It looks as those rsh opens up security issues (the backup has to run as root). Which one should be used and does someone have the links to set up allowed connections. In what I... (7 Replies)
Discussion started by: jphess
7 Replies

6. Shell Programming and Scripting

ftp, rlogin , rcp, rsh are not wroking

Hi Friends I am facing one problem, I am not able to use ftp, rlogin , rcp, rsh in a particular server. when I am trying to ftp certain file from that server it is giving Connection closed by remote host. Now from other unix box I am not able to rlogin that particular server. as .rhosts... (3 Replies)
Discussion started by: itsjoy2u
3 Replies

7. Solaris

Can ftp but not telnet/ssh/rsh

Hi , I have a Solaris 9 machine in which I can ftp but telnet/rsh/ssh is not working, although it was working before. I cannot also log in through the console. I get the banner for telnet but it kicks me out. Any ideas? rte (2 Replies)
Discussion started by: run_time_error
2 Replies

8. UNIX for Dummies Questions & Answers

telnet, rlogin, ssh login probblem

Hello Friends, I had an IRIX box won't let me login with any IDs (even root) Telnet, Rlogin, SSh. However, I can login by single user with root ID. Telnet login >>> Connection closed by forgeign host. Rlogin >>> Connection closed SSh login >>> connection to address ???.????.???.??? ... (1 Reply)
Discussion started by: anphdula
1 Replies

9. Programming

rlogin/rsh incoming port

Hi all, In need to know why my sample code below that connect to a rlogind (513) fails, but original unix rlogin does not ? (.rhosts is verified to be correct) I heard rlogin/rsh bind to a reserved port before connecting to the rlogin server. what are they ??? s = socket(AF_INET,... (1 Reply)
Discussion started by: andryk
1 Replies

10. UNIX for Dummies Questions & Answers

rsh & rlogin

I'm trying to execute the next command: " rsh CompName date " which means i want to get the date from a machine which i have its CompName. but i get the answer : "Connection refused" what do i need to do ? how can i sign myself as user or guest in the other machine ? thanks in... (2 Replies)
Discussion started by: Inbal
2 Replies
Login or Register to Ask a Question