Skip to content

Instantly share code, notes, and snippets.

View scross01's full-sized avatar

Stephen Cross scross01

  • Oracle
  • Ottawa, Canada
View GitHub Profile
@scross01
scross01 / opc-sec-rule-ssh.tf
Last active August 28, 2017 19:18
Terraform OPC Provider Security Rule to enable ingress SSH from the Public Internet to an Instance with a Public IP on a Shared Network interface
resource "opc_compute_security_list" "enable-ssh" {
name = "Enable-SSH-access"
policy = "DENY"
outbound_cidr_policy = "PERMIT"
}
resource "opc_compute_sec_rule" "allow-ssh" {
name = "Allow-ssh-access"
source_list = "seciplist:/oracle/public/public-internet"
destination_list = "seclist:${opc_compute_security_list.enable-ssh.name}"
@scross01
scross01 / config
Created June 20, 2017 20:59
SSH proxy connection through a bastion host (~/.ssh/config)
Host my-private-host
Hostname <PRIVATE_IP>
User opc
IdentityFile ~/.ssh/id_rsa
ProxyCommand ssh -i ~/.ssh/id_rsa opc@<BASTION_IP> -W %h:%p %r
@scross01
scross01 / config
Created June 20, 2017 17:07
SSH keep-alive options (~/.ssh/config)
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
@scross01
scross01 / opc-set-shared-network-resolver.sh
Last active May 28, 2017 12:49
Oracle Compute Cloud. Add the nameserver to /etc/resolv.conf for an interface with a private ip on the shared network
# get the IP address for eth0
private_ip=$(/sbin/ifconfig eth0 | grep 'inet ' | awk '{ print $2 }')
# shared network private IPs are in a /30 subnet, nameserver is IP address -1
nameserver=$(echo ${private_ip} | awk -F. '{ sub("."$4,"."$4-1) } 1')
# append to /etc/resolv.conf
sudo sed -i -e "\$anameserver ${nameserver}" /etc/resolv.conf