SSH to lab machines with keypairs

For my colleagues.

SSH to lab machines using RSA keys

Make a keypair

First, check if you have any keypair.

$ ls -a ~/.ssh

If you don’t see any keypair like id_rsa and id_rsa.pub, make a new one.

$ ssh-keygen -t rsa -b 2048

Get inside the firewall

Now connect to a machine. You can do this step either through VPN or from inside the school firewall (indeed they’re same in this situation). VPN server name is like kaguvpn.ed.tus.ac.jp.

Once gotten inside the firewall, open the machine list. Choose one with its location UG.

Copy the public key to a server

In this step, stay in the firewall.

Copy your public key to authorized_keys.

$ cat ~/.ssh/id_rsa.pub | ssh ${username}@${server_IP_address} "cat >> ~/.ssh/authorized_keys"

Replace ${username} as your name, ${server_IP_address} as the lab machine’s IP address in the list.

Debian asks for your password, so respond to the request.

Connect with SSH keys

Now you can connect to lab machines using ssh with the keypair (from inside the firewall).

$ ssh ${username}@${server_IP_address}

Well done!