Skip to content

Instantly share code, notes, and snippets.

@da667
Last active August 13, 2021 17:11
Show Gist options
  • Save da667/802c5bb2be78a52f9a57bde03483c1c2 to your computer and use it in GitHub Desktop.
Save da667/802c5bb2be78a52f9a57bde03483c1c2 to your computer and use it in GitHub Desktop.
SSH config file for Chapter 16: Routing and Remote Access for Bare-Metal hypervisors: Contains root user connection profiles
Host bastion_host
Hostname 10.0.0.162
User ayy
LocalForward 9000 172.16.1.3:22
LocalForward 9001 172.16.1.4:22
LocalForward 9002 172.16.2.2:22
DynamicForward 9003
Host bastion_host_root
Hostname 10.0.0.162
User root
LocalForward 9000 172.16.1.3:22
LocalForward 9001 172.16.1.4:22
LocalForward 9002 172.16.2.2:22
DynamicForward 9003
Host siem
Hostname 127.0.0.1
Port 9000
User ayy
Host siemroot
Hostname 127.0.0.1
Port 9000
User root
Host ips
Hostname 127.0.0.1
Port 9001
User ayy
Host ipsroot
Hostname 127.0.0.1
Port 9001
User root
Host kali
Hostname 127.0.0.1
Port 9002
User ayy
Host kaliroot
Hostname 127.0.0.1
Port 9002
User root
@da667
Copy link
Author

da667 commented Apr 8, 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. Refer to Section 16.9.1.1 for more details. 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 you've opted to enable SSH access as the root user on the bastion host and/or all of the lab virtual machines, and that the user created during OS install for all four systems is ayy. This system also assumes that the bastion host's IP address is 10.0.0.162. Users will need to modify the Hostname field of the bastion_host and bastion_host_root profiles to reflect the actual IP address of your 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 and bastion_host_root host entries as necessary. If you needed to use different port numbers for the LocalForward tunnels, modify the Port field for the siem, siemroot, ips, ipsroot, kali and kaliroot 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 OSX, 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

Test to ensure the config file is set up properly by running the following commands:

ssh bastion_host
ssh bastion_host_root
ssh siem
ssh siemroot
ssh ips
ssh ipsroot
ssh kali
ssh kaliroot

If key-based authentication was enabled, running these commands will either result in an instant SSH session or a prompt for the SSH private key's passphrase.

"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