Updating.
This commit is contained in:
parent
9140b2f983
commit
577a12d5c0
24
README.md
Normal file
24
README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Tab Magic
|
||||||
|
|
||||||
|
Tab Magic is a shell-alias building tool for *NIX operating systems.
|
||||||
|
|
||||||
|
It utilizes doing a DNS zone-transfer and building bash aliases based on A, CNAME, and TXT records.
|
||||||
|
|
||||||
|
You will need to create a config.json with your information in it:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"resolver": "172.19.0.5",
|
||||||
|
"resolverPort": 53,
|
||||||
|
"domains": [ "kc.linuxrocker.com"],
|
||||||
|
"jumpHost": "jump01.kc.linuxrocker.com",
|
||||||
|
"splitString": ".linuxrocker",
|
||||||
|
"windowsGeometry": "1600x900"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For Tab_Magic to do proper host detection, The following TXT record options are available:
|
||||||
|
|
||||||
|
* SSH_PORT - SSH Port will allow you to specify a custom SSH Port for the remote host. Valid: 1-65536
|
||||||
|
* OS_FAMILY - Can be either "ESXi", "Ubiquiti", or "Windows". If ESXi, it will log in as root with no sudo opts. If Ubiquiti, it will not use sudo. If Windows, it will use the rdesktop command line tool.
|
||||||
|
* REMOTE_USER - This is not implemented yet, but you will be able to specify a custom username for the remote host.
|
@ -3,5 +3,6 @@
|
|||||||
"resolverPort": 53,
|
"resolverPort": 53,
|
||||||
"domains": [ "kc.linuxrocker.com"],
|
"domains": [ "kc.linuxrocker.com"],
|
||||||
"jumpHost": "jump01.kc.linuxrocker.com",
|
"jumpHost": "jump01.kc.linuxrocker.com",
|
||||||
"splitString": ".linuxrocker"
|
"splitString": ".linuxrocker",
|
||||||
|
"windowsGeometry": "1600x900"
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ type Config struct {
|
|||||||
Domains []string `json:"domains"`
|
Domains []string `json:"domains"`
|
||||||
JumpHost string `json:"jumpHost"`
|
JumpHost string `json:"jumpHost"`
|
||||||
SplitString string `json:"splitString"`
|
SplitString string `json:"splitString"`
|
||||||
|
WindowsGeometry string `json:"windowsGeometry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetConfig gets the configuration values for the api using the file in the supplied configPath.
|
//GetConfig gets the configuration values for the api using the file in the supplied configPath.
|
||||||
|
@ -22,19 +22,35 @@ func CreateShellAliases(data []string, username string, config config.Config) {
|
|||||||
racOpts := "-AXt -l"
|
racOpts := "-AXt -l"
|
||||||
hop := "ssh -AXt"
|
hop := "ssh -AXt"
|
||||||
prerac := ""
|
prerac := ""
|
||||||
|
windowsGeometry := config.WindowsGeometry
|
||||||
|
|
||||||
host := strings.TrimRight(hostname, stringSplit)
|
host := strings.TrimRight(hostname, stringSplit)
|
||||||
fqdn := hostname
|
fqdn := hostname
|
||||||
|
|
||||||
greentext := "tput -T xterm setaf 2; "
|
greentext := "tput -T xterm setaf 2; "
|
||||||
// redtext := "tput -T xterm setaf 1; "
|
redtext := "tput -T xterm setaf 1; "
|
||||||
resettext := "tput -T xterm sgr0; "
|
resettext := "tput -T xterm sgr0; "
|
||||||
message := fmt.Sprintf("%vecho \"Authenticating as: %v\";%v", greentext, remoteUser, resettext)
|
message := fmt.Sprintf("%vecho \"Authenticating as: %v\";%v", greentext, remoteUser, resettext)
|
||||||
|
|
||||||
if txt == "" {
|
// TXT Record Parsing
|
||||||
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
if strings.Contains(txt, "SSH_PORT") {
|
||||||
} else {
|
port := strings.TrimLeft(txt, "SSH_PORT=")
|
||||||
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
racOpts = fmt.Sprintf("ssh -AXt -p %v -l", port)
|
||||||
|
} else if strings.Contains(txt, "OS_FAMILY") {
|
||||||
|
osFamily := strings.Split(txt, "=")
|
||||||
|
if osFamily[1] == "ESXi" {
|
||||||
|
sudo = ""
|
||||||
|
remoteUser = "root"
|
||||||
|
} else if osFamily[1] == "Windows" {
|
||||||
|
prerac = fmt.Sprintf("%vecho \"Password: \"; %v", redtext, resettext)
|
||||||
|
hop = "ssh -XCAT"
|
||||||
|
rac = "rdesktop"
|
||||||
|
windowsDomain := ""
|
||||||
|
racOpts = fmt.Sprintf("-r clipboard:CLIPBOARD -a 16 -k en-us -g %v -p - %v -u", windowsGeometry, windowsDomain)
|
||||||
|
sudo = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user