(mail)
(mail)
(mail)

CIS241

System-Level Programming and Utilities

Advanced SSH - Keys and Hostnames

Erik Fredericks, frederer@gvsu.edu
Fall 2025

Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers

CIS241 | Fredericks | F25 | 6-advanced-ssh

ssh is fine - but...

  • Lots of typing!
  • You have to remember eos##.cis.gvsu.edu
    • Or worse, an IP address
  • Also you can't see your password
    • False it is hunter2 but I just see *******

top-corner (yuck)

CIS241 | Fredericks | F25 | 6-advanced-ssh

Let's create a hostname alias!

In your ~/.ssh/ directory:

  • Create (or edit) a file named config

In that file, add:

Host eos01
Hostname eos01.cis.gvsu.edu
User yourusername

And then: ssh eos01

CIS241 | Fredericks | F25 | 6-advanced-ssh

Now, ssh keys!

We can skip the whole password thing and use encrypted keys!

top-right (big key)

Default locations (on the machine you're ssh'ing from)

  • ~/.ssh/id_rsa - private key
  • ~/.ssh/id_rsa.pub - public key
CIS241 | Fredericks | F25 | 6-advanced-ssh

Using ssh keys

  1. First, make sure you don't have them already
  • ls -la ~./ssh
  1. Generate the keys
  • ssh-keygen
  1. Share the public key (add to ~/.ssh/authorized_keys)
  • ssh-copy-id -i path_to_key username@server
CIS241 | Fredericks | F25 | 6-advanced-ssh

Common issues

  • Errors with authorized_keys file

    • Make sure the file exists: touch ~/.ssh/authorized_keys
  • Wrong permissions

    • chmod 600 ~/.ssh/authorized_keys
    • chmod 700 ~/.ssh
  • If you have ssh and ssh-keygen but not ssh-copy-id

    • We can manually copy the key and add it to the file
      • scp ~/.ssh/id_rsa.pub username@hostname:~
    • Login to server via ssh
      • cat id_rsa.pub >> ~/.ssh/authorized_keys

top-corner (little miss whoops)

CIS241 | Fredericks | F25 | 6-advanced-ssh

may need to chmod 600 on the file