Agenda: exercises-cisco-config.txt

File exercises-cisco-config.txt, 7.4 KB (added by dean, 5 years ago)
Line 
1% Cisco Config Elements
2%
3% Network Monitoring and Management
4
5# Introduction
6
7## Goals
8
9* Learn the basic set of IOS commands required to enable SSH on your Cisco
10  Switch or Router
11 
12## Notes
13
14* Commands preceded with "$" imply that you should execute the command as
15  a general user - not as root.
16* Commands preceded with "#" imply that you should be working as root.
17* Commands with more specific command lines (e.g. "rtrX>" or "mysql>")
18  imply that you are executing commands on remote equipment, or within
19  another program.
20* If a command line ends with "\" this indicates that the command continues
21  on the next line and you should treat this as a single line.
22
23# Exercises Part I
24
25## Work in a group
26
27For this exercise you need to work in groups. Assign one person to type on
28the keyboard. There should be 4 people in group. For instance, members of
29Group 1 are those on pc1-pc4, Group 2 use pc5-pc8, Group 3 use pc9-12, etc

30
31If you are unsure of what group you are in refer to the Network Diagram on the
32classroom wiki by going to http://noc.ws.nsrc.org/ and clicking on the Network
33Diagram link.
34
35## Connect to your router
36
37Log in to your vm/pc image and install Telnet:
38
39~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40$ sudo apt-get install telnet
41~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42
43If it is already installed that is fine.
44
45Now connect to the router in your group:
46
47~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48$ telnet 10.10.N.254
49~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
51        username: cisco
52        password: cisco
53
54Display information about your router
55
56~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57routerN>enable                         
58Password:                                               (default pw "cisco")
59RouterN#show run                                (space to continue)
60RouterN#show int FastEthernet0/0
61RouterN#show ?                                  (lists all options)
62RouterN#exit                                    (log off router)
63~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
65
66## Configure your router to only use SSH
67
68These steps will do the following:
69
70* Create an ssh key for your router
71* Create an encrypted password for the user cisco
72* Encrypt the enable password (cisco)
73* Turn off telnet (unencrypted) access to your router
74* Turn on SSH (version 2) access to your router
75
76You need to work in groups of 4. Get together with the members of your router
77group and assign one person to enter commands. To start connect to one of the
78PCs in use by your group. From that PC image telnet to your router:
79
80~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81$ telnet rtrN.ws.nsrc.org       (or "telnet 10.10.N.254")
82~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83       
84        username: cisco
85        password: cisco
86
87~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88rtrN> enable                                            (en)
89password: cisco
90rtrN# configure terminal                        (conf t)
91rtrN(config)# aaa new-model
92rtrN(config)# ip domain-name ws.nsrc.org
93rtrN(config)# crypto key generate rsa
94
95        How many bits in the modulus [512]: 2048
96~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97       
98Wait for the key to generate. You can now specify passwords and they will be
99encrypted. First let's remove our cisco user temporarily, then we'll recreate
100the user:
101
102~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103rtrN(config)# no username cisco
104rtrN(config)# username cisco secret 0 <CLASS PASSWORD>
105~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106
107Now the cisco user's password (of <CLASS PASSWORD>) is encrypted. Next let's encrypt
108the enable password as well:
109
110~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111rtrN(config)# enable secret 0 <CLASS PASSWORD>
112~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113
114Now we'll tell our router to only allow SSH connections on the 5 defined
115consoles (vty 0 through 4):
116
117~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118rtrN(config)# line vty 0 4
119rtrN(config-line)# transport input ssh
120rtrN(config-line)# exit
121~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
123This drops us out of the "line" configuration mode and back in to the general
124configuration mode. Now we'll tell the router to log SSH-related events and to
125only allow SSH version 2 connections:
126
127~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128rtrN(config)# ip ssh logging events
129rtrN(config)# ip ssh version 2
130~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131
132Now exit from configuration mode:
133
134~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135rtrN(config)# exit
136~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137
138And, write these changes to the routers permament configuration:
139
140~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141rtrN# write memory                              (wr mem)
142~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143
144Ok. That's it. You can no longer use telnet to connect to your
145router.  You must connect using SSH with the user "cisco" and
146password <CLASS PASSWORD>.  The enable password is, also, <CLASS
147PASSWORD> - Naturally in a real-world situation you would use much
148more secure passwords.
149
150Before you exit your Telnet session be sure to test ssh connectivity
151from another PC in your group (or, open another terminal window).
152Do this in case you made a mistake to avoid locking yourself out
153of your router.
154
155First, try connection again with telnet:
156
157~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158$ telnet rtrN.ws.nsrc.org
159~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
161What happens? You should see something like:
162
163~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164Trying 10.10.N.254...
165telnet: Unable to connect to remote host: Connection refused
166~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167
168Now try connecting with SSH:
169
170~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171$ ssh cisco@rtrN.ws.nsrc.org
172~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173
174You should see something looks similar to this:
175
176~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
177The authenticity of host 'rtr2.ws.nsrc.org (10.10.2.254)' can't be     
178established. RSA key fingerprint is 93:4c:eb:ad:5c:4a:a6:3e:8b:9e:
1794f:e4:e2:eb:e4:7f. Are you sure you want to continue connecting
180(yes/no)?
181~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182
183Enter in "yes" and press ENTER to continue...
184
185Now you'll see the follwoing:
186
187~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188Password: <CLASSS PASSWORD>
189rtrN>
190~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191
192Type "enable" to allow us to execute privileged commands:
193       
194~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195rtrN> enable
196Password: <CLASS PASSWORD>
197rtrN#
198~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199
200Now let's view the current router configuration:
201
202~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203rtrN# show running                                      (sh run)
204~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205
206Press the space bar to continue. Note some of the entries like:
207
208~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
209enable secret 5 $1$p4/E$PnPk6VaF8QoZMhJx56oXs.
210.
211.
212.
213username cisco secret 5 $1$uNg1$M1yscHhYs..upaPP4p8gX1
214.
215.
216.
217line vty 0 4
218exec-timeout 0 0
219transport input ssh
220~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221
222You can see that both the enable password and the password for the user cisco
223have been encrypted. This is a good thing.
224
225Now you should exit the router interface to complete this exercise:
226
227~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228rtrN# exit
229~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230       
231And, if you still have your older Telnet session in another window
232be sure to exit from that as well.
233
234# NOTES
235
2361. If you are locked out of your router after this exercise let your
237    instructor know and they can reset your router's configuration back to its
238    original state.
2392. Please only do this exercise once. If multiple people do this exercise
240    it's very likely that access to the router will be broken.
2413. During the week you will configure items such as SNMP, Netflow and more on
242    your group's router. From now on you can simply connect to the router
243    directly from your laptop or desktop machine using SSH.