// Lesson 39 of 49 · IP services
SSH remote access and file transfer
Enabling SSH version 2, securing the VTY lines, and copying files with TFTP, FTP and SCP.
2 min read#ssh#tftp#scp
Enable SSH
SSH needs a hostname, a domain name, RSA keys and a local (or AAA) user:
SW1(config)# hostname SW1
SW1(config)# ip domain-name corp.example
SW1(config)# crypto key generate rsa modulus 3072
SW1(config)# ip ssh version 2
SW1(config)# username netadmin privilege 15 secret <STRONG-SECRET>
SW1(config)# line vty 0 15
SW1(config-line)# login local
SW1(config-line)# transport input ssh
SW1(config-line)# exec-timeout 10 0
transport input sshdisables Telnet on the VTY lines.- A switch needs a management IP (usually an SVI in a management VLAN) and a default gateway:
SW1(config)# interface vlan 99
SW1(config-if)# ip address 192.168.99.11 255.255.255.0
SW1(config-if)# no shutdown
SW1(config)# ip default-gateway 192.168.99.1 ! on a Layer 2 switch
Restrict who can connect
SW1(config)# access-list 5 permit 192.168.99.0 0.0.0.255
SW1(config)# line vty 0 15
SW1(config-line)# access-class 5 in
Verify
SW1# show ip ssh
SSH Enabled - version 2.0
SW1# show ssh
SW1# show users
From a PC: ssh netadmin@192.168.99.11.
Moving files
Used for IOS upgrades and configuration backups.
| Protocol | Transport | Security |
|---|---|---|
| TFTP | UDP 69 | None, no authentication — lab and trusted networks only |
| FTP | TCP 20/21 | Username/password in clear text |
| SCP | TCP 22 (SSH) | Encrypted and authenticated |
R1# copy running-config tftp:
Address or name of remote host []? 192.168.1.50
R1# copy tftp: flash:
R1# copy scp://netadmin@192.168.1.50/backup.cfg flash:
R1# show flash:
To use a router as an SCP server for pulling files from it: ip scp server enable (requires AAA authorisation).
Upgrading IOS — the outline
- Check flash space (
show flash:) and the current version (show version). - Copy the new image to flash (SCP preferred) and verify its hash:
verify /md5 flash:<image>. - Point the boot variable at the new image:
boot system flash:<image>. - Save and reload in a maintenance window.
Key points
- SSH needs hostname, domain name, RSA key (2048+ bits), local user,
login localandtransport input ssh. - Layer 2 switches need a management SVI and
ip default-gateway. - Limit VTY access with
access-class. - Prefer SCP over TFTP/FTP for file transfers.
Sign in to save your lesson progress across devices. You can read every published lesson without an account.