LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 05-10-2008, 03:44 AM   #1
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Rep: Reputation: 29
a script to access a switch within LAN


HI,

I have a manageable switch allied teleysin and for some reasons I need to write a script to enable and disable settings.

I wrote a small one but din't work


#/bin/bash

telnet 192.168.0.1

username
password

but when I run these three commands I get the loging prompt I don't get loging through script any ideas will appretiated.

thanks
 
Old 05-10-2008, 04:58 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You cannot pass username and password like this in a script. You have to use some communication tool like expect which is able to dialogue with interactive programs like telnet.
 
Old 05-10-2008, 06:11 AM   #3
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Original Poster
Rep: Reputation: 29
I have expect already but don't know how to make a login script. thanks for answer.
 
Old 05-10-2008, 06:44 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I cannot be of much help, but you can try to look for "expect telnet" in the LQ search page. You will find a lot of hits.
 
Old 05-10-2008, 11:38 AM   #5
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
being a managed switch it certainly has snmp abilities.
setup a private read/write community string and write a script to do the snmpset calls

just make sure you restrict the private community access to a network or single ip or firewall the port

I would advise using a community string that follows good password creation rules. Also snmp v.3 uses name/password

Last edited by frndrfoe; 05-10-2008 at 11:53 AM.
 
Old 05-10-2008, 11:42 AM   #6
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
you can even setup a management webpage that does the get and draws pretty pictures to show the current status
 
Old 05-12-2008, 03:26 AM   #7
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Original Poster
Rep: Reputation: 29
after seeing all suggations. I come to know that why not to try ssh I configured ssh on my swithc which details are.

SSH Configuration
Version ................... 1.5
Server Enabled ............ TRUE
Port ...................... 22
Host Key ID ............... 0
Host Key Bits ............. 1024
Server Key ID ............. 1
Server Key Bits ........... 768
Server Key Expiry(hours).. 1
Login Timeout(secs) ....... 60
Authentication Available .. Password,RSA
Ciphers Available ......... DES
Services Available ........ Shell,Cmd


but when I ssh from my system I do get the following error.

Selected cipher type <unknown> not supported by server.

don't know what this is.

thanks
 
Old 05-12-2008, 04:35 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by shahz View Post
Selected cipher type <unknown> not supported by server.
This is related to the cryptography used by ssh. The chiper you've selected in the configuration is DES, which is obsolete and highly discouraged because of its weakness. You can try to specify another chiper like 3DES and try to connect using the -c option of ssh. For example:
Code:
ssh -c 3des user@host
 
Old 05-12-2008, 04:40 AM   #9
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Original Poster
Rep: Reputation: 29
okay after having this command I do get the following error.

ssh -c 3des server

selected cipher type 3des not supported by server.

thanks
 
Old 05-12-2008, 05:01 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
What do you get using the following?
Code:
ssh -c des server
since the available chiper seems to be only DES.
 
Old 05-12-2008, 05:10 AM   #11
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Original Poster
Rep: Reputation: 29
and if I do the following it works but I do get the following message.


ssh -l user -c des IP

warning: use of DES is strongly discouraged due to cryptographic weaknesses.

it works is that a security hole or what???

Last edited by shahz; 05-12-2008 at 05:17 AM.
 
Old 05-12-2008, 05:15 AM   #12
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Yes. It is a security hole in the sense that the cryptography used by ssh can be stronger than that. Anyway better than the telnet solution which sends traffic in clear text. And if your switch configuration supports only DES you have no other chance to access it.
 
Old 05-12-2008, 06:04 AM   #13
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Original Poster
Rep: Reputation: 29
thanks for your quick response

I want to be logged in through a script what key I need to copy to the switch and what will be the command for it. means I don't want to give passwords all the time for switch. then I think I am done.

thanks
 
Old 05-12-2008, 08:07 AM   #14
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You have to generate a private/public key pair using ssh-keygen, then you have to copy the public key (e.g. id_dsa.pub) to the file ~/.ssh/authorized_keys on the switch.
Code:
scp -c des  name_of_key.pub  user@IP:.ssh/authorized_keys
be sure that permissions of directory .ssh are set to 700 (that is drwx------) and permissions of the private key on the local machine are set to 600 (-rw-------) otherwise ssh will refuse to connect using public key authentication.
Maybe when connecting to the switch you have to specify the name of the key, if it is not the default name. In this case you have to use the -i option:
Code:
ssh -c des -i name_of_key user@IP
Let me know if it works. Bye.
 
Old 05-13-2008, 03:22 AM   #15
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Original Poster
Rep: Reputation: 29
No it din't work what I did is as follow

I made private and public keys I had them within /root/.ssh/id_rsa.pub and id_rsa

I named it publickey

I followed the above command to copy it over the swith with the command.

scp -c des publickey user@IP:.ssh/authorized_keys

i get the following error.
write failed flushing stdout buffer.
conncetion to 192.168.0.1 closed by remote host.

don't know what I am missing
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to view all the packets in LAN connected to switch LinuxNewbie999 Linux - Networking 6 09-20-2007 07:40 AM
LAN cannot access other LAN systems, only WAN Myrion Linux - Networking 1 09-06-2007 07:29 PM
Configuring a Linux LAN with Switch rm_-rf_windows Linux - Networking 10 07-10-2007 05:22 PM
Need pointers for LAN, ADSL->Switch->2 coputers Ork Linux - Networking 1 03-07-2005 04:14 PM
I need my LAN users to access the internet using automatic configuratin script on RH9 akohamen Linux - Networking 1 04-20-2004 03:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 05:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration