# ~/.ssh/config
# vim: ft=sshconfig:sw=2:ts=2:sts=2:tw=80:fdm=marker:fdl=0:noml:
# see: <https://man.openbsd.org/ssh>
# see: <https://man.openbsd.org/ssh_config>
IgnoreUnknown Include
Include config_private

AddKeysToAgent yes
SendEnv LANG LC_*

Host to go
	HostName %h.local
	ForwardAgent yes
	RemoteForward 7062 127.0.0.1:7062

#Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"

Host *
    # Store keys in the client when first using them.
    AddKeysToAgent yes

    # Make all sessions to the same host share a single connection.
    ControlMaster auto
    ControlPersist 120
    ControlPath ~/.ssh/sockets/socket-%r@%h:%p

# -- OPTIONS -----------------------------------------------------------
ForwardAgent no
HashKnownHosts yes
ServerAliveInterval 60

# -- CONNECTION SHARING ------------------------------------------------
ControlMaster=yes
ControlPersist=5s
# see: https://overflow.adminforge.de/exchange/superuser.com/questions/45342/#45509
ControlPath=/dev/shm/control:%h:%p:%r

# Default
Host *
    KeepAlive yes
    ControlMaster auto
    ControlPath /tmp/ssh-%r@%h:%p
    GSSAPIAuthentication no
    HashKnownHosts no

Host *
    AddKeysToAgent yes
    AddressFamily any
    # enable persistent connection multiplexing
    #ControlMaster auto
    #ControlPath ~/.ssh/s/%C
    #ControlPath ~/.ssh/-%r@%h:%p
    #ControlPath ~/.ssh/%r@%h:%p
    #ControlPersist 72000
    #ControlPersist 600
    #ForwardAgent yes
    #ForwardX11Trusted yes
    HashKnownHosts yes
    NoHostAuthenticationForLocalhost yes
    PermitLocalCommand yes
    ServerAliveInterval 60
    StrictHostKeyChecking no
    #TCPKeepAlive yes
    UpdateHostKeys ask
    UserKnownHostsFile ~/.ssh/known_hosts
    #VisualHostKey yes

Host localhost
    UserKnownHostsFile /dev/null

# private config
Include ~/.ssh/config.local

# go
Host to
    Hostname 192.168.50.10
    IdentitiesOnly yes
    IdentityFile ~/.ssh/id_ed25519
    Port 22
    User house

# to
Host go
    Hostname 192.168.50.55
    IdentitiesOnly yes
    IdentityFile ~/.ssh/id_ed25519
    Port 31322
    User house

# -- HOSTS -------------------------------------------------------------
Host local
    HostName 127.0.0.1
    Port 9922
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
Host local
    Hostname 127.0.0.1
    Port 9922
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

# ssh tunnel!
Host tunnel
    HostName database.example.com
    IdentityFile ~/.ssh/user.example.key
    LocalForward 9906 127.0.0.1:3306
    User user
