LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   auto-login script for connecting to remote m/n by using telnet/ftp/ssh (https://www.linuxquestions.org/questions/programming-9/auto-login-script-for-connecting-to-remote-m-n-by-using-telnet-ftp-ssh-396850/)

Uday123 12-27-2005 08:57 AM

auto-login script for connecting to remote m/n by using telnet/ftp/ssh
 
Hi all,

I need a script for getting connection to remote machine by using ssh/telnet/ftp.
and that script should do
1.copy the files/scripts from my machine to remote machine.
2.execute the script at remote machine and copy the output file from remote m/n to my local machine.

I have done with the connectivity part by using Expect script.
#!/usr/bin/expect -f
spawn telnet <IP address>
expect -re "login"
send "username\n"
expect -re "Password"
send "password of the user\n"
interact

Can you please help me for getting the other 2 requirements.

Thanks in advance

acid_kewpie 12-27-2005 09:51 AM

this is just weird, i've seen like 5 expect questions today, and hardly any ever before...

anywho... firslty don't use telnet. secondsly use ssh, thirdly use preshared keys to mean you don't need to log in at all. you've no need to run expect at all.

ssh user@server mycommandiwanttorun > localoutputfile.txt

mariusica_sb 04-13-2009 01:10 PM

RE: Auto Login with telnet
 
Quote:

Originally Posted by Uday123 (Post 2017165)
Hi all,

I need a script for getting connection to remote machine by using ssh/telnet/ftp.
and that script should do
1.copy the files/scripts from my machine to remote machine.
2.execute the script at remote machine and copy the output file from remote m/n to my local machine.

I have done with the connectivity part by using Expect script.
#!/usr/bin/expect -f
spawn telnet <IP address>
expect -re "login"
send "username\n"
expect -re "Password"
send "password of the user\n"
interact

Can you please help me for getting the other 2 requirements.

Thanks in advance

Hi all

The Auto login part works great
I have been searching for days for a thing like that and this is the first one wich really worked
Good Script
10x

pawan_linux 01-21-2010 05:03 AM

hi freinds
 
The above autologin script is not working on my system.
the error is
spawn command not found
send command not found

am i Have to install these two programs prior to make this script runing?If yes,How?

please revert

melk0r101 02-15-2011 05:14 PM

Hi,

I made a free open source tool named SendCommand that would permit you to automate logins (ssh/telnet) and command execution on your routers. It has been developed in perl and it is highly customizable.

Check it out:
https://sourceforge.net/projects/sendcommand/

cheers

floorripper 10-12-2011 11:31 AM

COOL SCRIPT MAN! AWESOME!
I did this.

apt-get install expect
cd /usr/sbin


vi autologin

#!/usr/bin/expect -f
spawn telnet 10.149.100.3
expect -re "Username:"
send "iamuser\n"
expect -re "Password"
send "thebest\n"
interact

So we create a file, where we can specify an IP address of the remote machine, your password and username.
I am wondering how to make it dynamic for any ip like: autologin 10.10.1.1


All times are GMT -5. The time now is 11:45 AM.