Discovering computer networks: hands on in the Open Networking Lab
Discovering computer networks: hands on in the Open Networking Lab

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

Free course

Discovering computer networks: hands on in the Open Networking Lab

15.3 Secure shell access

Secure Shell (SSH) is a protocol, similar to Telnet, for remote access to computers and other devices. Unlike Telnet, SSH is secure because all traffic is encrypted, and it is essential to use it for remote access over the internet. SSH uses the same type of encryption as secure websites.

Watch the video below, which is about 3 minutes long. You will see how to generate SSH keys and to configure the router only to accept connections from particular users.

Secure shell access

Download this video clip.Video player: 82_secure_shell_access.mp4
Skip transcript


Telnet is an insecure protocol for connecting to terminals – SSH, or Secure Shell, should be used instead wherever you need to make a connection over the internet because all the data that travels over the network is encrypted. It is a bit more trouble to configure, but an essential stage in making your router properly secure.

I am going to get the router to generate some cryptographic keys that will be used to set up encrypted connections. Before I do that, I need to make sure that the router has been given a host name. To do this, we go to global configuration and use the command hostname ONLRouter1. I also need to add a domain name – this would be the domain name offor whatever organisation owns the router but I am going to use From global configuration, I will use the command ip domain-name

Now I can go ahead and create the keys that SSH will use. I will use the command crypto key generate rsa, then I will choose a key size – the bigger the number the more complex and secure the key becomes – I will use 2048, although it will take a while to be generated by the router. The key generation uses the host and domain name, which is why I had to set that up first. The new key is unique to that router, so the bad guys can’t setup another router and pretend to be me.

I need to do several more things to make the security as tight as a I can.

First I am going to set up an individual user for the router with their own password, rather than have a shared password for all users. From global configuration mode, type userthen the username, so jason, followed by secretand the user’s password, onlssh.

Secondly, I’m going to set the vty line to use the new configuration, so use line vty 0 15. To make this use the username I created, I will enter login local.

Finally, to force SSH to be used, I’ll use the command transport input ssh – this will disable Telnet and force the users to use SSH.

Let’s test our configuration. I’ll try first to Telnet from the PC to the router – as you can see I get ‘denied access’ with the network error ‘connection refused’.

Now I’ll try SSH. The command for that is ssh -l followed by the username, so jason, and then followed by the IP address of the router, which is I’m now prompted for my password, which if I remember correctly was onlssh. You can see the banner I made earlier.

If you’re using PuTTY to connect to a real router, you’ll get a key caching message like this one. If you’re sure you have the correct IP for the router then you can answer ‘Yes’ and you won’t receive this message again.

Now I’ve made my router as secure as possible. Only specified individuals can log in, they must know their password, and they must use SSH. If we look at a packet capture of the SSH session, you will see the data is encrypted and we can no longer see the passwords; SSH encryption is very strong and effectively unbreakable.

End transcript
Interactive feature not available in single page view (see it in standard view).

Activity 5 Try it out

10 minutes

  1. Open PT Anywhere [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)] in a new tab or window so you can read these instructions.

    In this activity you will configure the router in the network to only accept SSH connections from the PC.

  2. Open the router console and enter global configuration mode using the password ‘opennetlab’.

  3. Set the hostname and domain name as ‘ONLRouter1’ and ‘’.

    Generate the SSH keys with a size of 2048.

  4. Create a username, either ‘jason’ or your own name, with a secret password such as ‘onlssh’.

  5. Make sure that SSH is used rather than Telnet for connections.

  6. Now open the PC command line and start an SSH session to the router, giving the appropriate password.

  7. Confirm that you are connected to the router.

  8. Finish the SSH session by entering exit.

  9. Confirm that you can no longer connect to the router using Telnet.


Some configuration is required before SSH can be used. A set of keys must be generated on the router, and this will use information such as the router name and a domain name to generate unique keys.

Open the router console window and enter global configuration mode. Set the hostname with the command hostname ONLRouter1 and the domain name with command ip domain-name (You would replace these by appropriate names in a real installation.)

Use the command crypto key generate rsa, giving an appropriate key size such as 2048, to create the keys.

To create a user account with a secret password, enter a command such as username jason secret onlssh.

To ensure that only SSH is accepted for connection, the vty lines must be configured with a sequence of commands. First, use line vty 0 15 to enter line configuration mode. Then login local will require a username to be given, and transport input ssh will mean that only SSH connections are accepted.

This completes the setup for the router. To test the connection, you will need to turn to the command line on the PC.

To open an SSH session, you should enter the command ssh -l jason, giving the password ‘onlvty’ which you previously set on the router. You will see the message of the day and the prompt will change to ‘Router>’ showing that you are now giving commands to the router.

You can now work with the router’s command line, for example entering global configuration mode (you will need the password ‘opennetlab’) and show the running configuration.

You should exit from the SSH session using exit and confirm that you are back on the PC command line.


Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371