Skip to content

Instantly share code, notes, and snippets.

@da667
Last active August 13, 2021 17:45
Show Gist options
  • Save da667/652ebe408b65d5cc8a289a4889c46798 to your computer and use it in GitHub Desktop.
Save da667/652ebe408b65d5cc8a289a4889c46798 to your computer and use it in GitHub Desktop.
SSH config file for Building Virtual Machine Labs Chapter 16: Routing and Remote Access for Bare-Metal Hypervisors
Host bastion_host
Hostname 10.0.0.163
User ayy
LocalFoward 9000 172.16.1.3:22
LocalFoward 9001 172.16.1.4:22
LocalFoward 9002 172.16.2.2:22
DynamicFoward 9003
Host siem
Hostname 127.0.0.1
Port 9000
User ayy
Host ips
Hostname 127.0.0.1
Port 9001
User ayy
Host kali
Hostname 127.0.0.1
Port 9002
User ayy
@da667
Copy link
Author

da667 commented Aug 13, 2021

This is a sample ~/.ssh/config file for students reading Building Virtual Machine Labs, specifically, chapter 16 -- Routing and Remote Access for Bare-Metal Hypervisors. This SSH config file assumes that you are using the default subnet assignments (e.g. 172.16.1.0/24 and 172.16.2.0/24), and that the student has configured a bastion host VM, raspberry pi or other hardware, and that its IP address is 10.0.0.163. If necessary, modify the IP address in the Hostname field under Host bastion_host . This config file also assumes that the user created during OS install for all systems is ayy. Modify the User field to reflect the name of the user you wish to log in as over SSH as necessary.

If you need to modify the IP address for the bastion_host, modify the IP address in the Hostname field under Host bastion_host. If you need to adjust the IP address for the IPS, SIEM, or Kali virtual machines, modify the LocalForward field of the bastion_host as necessary. If you needed to use different port numbers for the LocalForward tunnels, modify the Port field for the siem, ips, and/or kali Host entries. Likewise modify the User field to reflect the name of the user you wish to log in as over SSH as necessary.

To install this file on Linux or MacOS, run the following commands:

ls -al ~/.ssh

if the output of this command indicates that the .ssh directory doesn't exist:

mkdir ~/.ssh
chmod 700 ~/.ssh

Finally, copy this file to the .ssh directory

cp config ~/.ssh/config
chmod 600 ~/.ssh/config

In order to test and ensure the config file is set up properly, students must first run the command ssh bastion_host. Once an SSH session to the bastion host system has been established, open a new terminal session and try the following commands:

ssh siem
ssh ips
ssh kali

After running each of these commands, students will be prompted for the password of the specified user on each VM. Once you enter the password, confirm you are logged on to the correct virtual machine.

"I already have a ~/.ssh/config file. Wat do?"

cp ~/.ssh/config ~/.ssh/config.old
cat config >> ~/.ssh/config

These commands will back up the existing ssh config file, and append the content from the sample config file to the existing config file. if problems occur, the command cp ~/.ssh/config.old ~/.ssh/config can be used to restore the backed up ssh config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment