8000 GitHub - geodavies/magic-mole: Bash network tunnel manager
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

geodavies/magic-mole

{"props":{"initialPayload":{"allShortcutsEnabled":false,"path":"/","repo":{"id":151745062,"defaultBranch":"master","name":"magic-mole","ownerLogin":"geodavies","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2018-10-05T15:55:25.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/19825446?v=4","public":true,"private":false,"isOrgOwned":false},"currentUser":null,"refInfo":{"name":"master","listCacheKey":"v0:1538754927.0","canEdit":false,"refType":"branch","currentOid":"8686c79d04aae0270936d1df1a523a4f9fffdb7f"},"tree":{"items":[{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"example-tunnels.csv","path":"example-tunnels.csv","contentType":"file"},{"name":"magic-mole.sh","path":"magic-mole.sh","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":null,"totalCount":4,"showBranchInfobar":false},"fileTree":null,"fileTreeProcessingTime":null,"foldersToFetch":[],"treeExpanded":false,"symbolsExpanded":false,"isOverview":true,"overview":{"banners":{"shouldRecommendReadme":false,"isPersonalRepo":false,"showUseActionBanner":false,"actionSlug":null,"actionId":null,"showProtectBranchBanner":false,"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_repo","releasePath":"/geodavies/magic-mole/releases/new?marketplace=true","showPublishActionBanner":false},"interactionLimitBanner":null,"showInvitationBanner":false,"inviterName":null,"actionsMigrationBannerInfo":{"releaseTags":[],"showImmutableActionsMigrationBanner":false,"initialMigrationStatus":null}},"codeButton":{"contactPath":"/contact","isEnterprise":false,"local":{"protocolInfo":{"httpAvailable":true,"sshAvailable":null,"httpUrl":"https://github.com/geodavies/magic-mole.git","showCloneWarning":null,"sshUrl":null,"sshCertificatesRequired":null,"sshCertificatesAvailable":null,"ghCliUrl":"gh repo clone geodavies/magic-mole","defaultProtocol":"http","newSshKeyUrl":"/settings/ssh/new","setProtocolPath":"/users/set_protocol"},"platformInfo":{"cloneUrl":"https://desktop.github.com","showVisualStudioCloneButton":false,"visualStudioCloneUrl":"https://windows.github.com","showXcodeCloneButton":false,"xcodeCloneUrl":"xcode://clone?repo=https%3A%2F%2Fgithub.com%2Fgeodavies%2Fmagic-mole","zipballUrl":"/geodavies/magic-mole/archive/refs/heads/master.zip"}},"newCodespacePath":"/codespaces/new?hide_repo_select=true\u0026repo=151745062"},"popovers":{"rename":null,"renamedParentRepo":null},"commitCount":"11","overviewFiles":[{"displayName":"README.md","repoName":"magic-mole","refName":"master","path":"README.md","preferredFileType":"readme","tabName":"README","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMagic Mole\u003c/h1\u003e\u003ca id=\"user-content-magic-mole\" class=\"anchor\" aria-label=\"Permalink: Magic Mole\" href=\"#magic-mole\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eBash network tunnel manager\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRequired Packages\u003c/h3\u003e\u003ca id=\"user-content-required-packages\" class=\"anchor\" aria-label=\"Permalink: Required Packages\" href=\"#required-packages\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003egrep\u003c/li\u003e\n\u003cli\u003eawk\u003c/li\u003e\n\u003cli\u003esed\u003c/li\u003e\n\u003cli\u003ecat\u003c/li\u003e\n\u003cli\u003eautossh\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eInstalling\u003c/h3\u003e\u003ca id=\"user-content-installing\" class=\"anchor\" aria-label=\"Permalink: Installing\" href=\"#installing\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFirst start by cloning this repository\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"cd \u0026lt;your-git-folder\u0026gt;\ngit clone https://github.com/geodavies/magic-mole.git\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003ecd \u0026lt;your-git-folder\u0026gt;\ngit clone https://github.com/geodavies/magic-mole.git\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eNext we need to configure which tunnels you want to use. This script will look for the file \u003cem\u003eexample-tunnels.csv\u003c/em\u003e\nfor the configuration of the tunnels by default. This location can be changed by updating the location at the top of the script.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe \u003cem\u003eexample-tunnels.csv\u003c/em\u003e file inside this repository can be used as a starting point but you will likely want to move this somewhere more permanent in the long run. The below commands for your system will move the \u003cem\u003eexample-tunnels.csv\u003c/em\u003e file to your home directory and change the location in the script. If you already have a \u003cem\u003etunnels.csv\u003c/em\u003e file in your home directory it will be replaced, so make sure you back it up first or skip the second command.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eLinux\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"cd magic-mole\ncp example-tunnels.csv /home/$USER/tunnels.csv\nsed -i 's/^input=.*$/input=\u0026quot;\\/home\\/$USER\\/tunnels.csv\u0026quot;/g' magic-mole.sh\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003ecd magic-mole\ncp example-tunnels.csv /home/$USER/tunnels.csv\nsed -i 's/^input=.*$/input=\"\\/home\\/$USER\\/tunnels.csv\"/g' magic-mole.sh\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eMacOS\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"cd magic-mole\ncp example-tunnels.csv /Users/$USER/tunnels.csv\nsed -i '' 's/^input=.*$/input=\u0026quot;\\/Users\\/$USER\\/tunnels.csv\u0026quot;/g' magic-mole.sh\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003ecd magic-mole\ncp example-tunnels.csv /Users/$USER/tunnels.csv\nsed -i '' 's/^input=.*$/input=\"\\/Users\\/$USER\\/tunnels.csv\"/g' magic-mole.sh\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eYou can now execute the script directly from the git repository directory if you choose but you may want to\ncreate a symlink to the script so it can be executed from anywhere in the terminal.\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"sudo ln -s $PWD/magic-mole.sh /usr/local/bin/mm\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003esudo ln -s $PWD/magic-mole.sh /usr/local/bin/mm\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe script can now be run from anywhere by using the command '\u003cem\u003emm\u003c/em\u003e'\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eTo have the tunnels start automatically on login, add the following to the bottom of ~/.profile:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"mm start\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003emm start\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cem\u003eNote this script is currently limited to only make connections to servers which already have the public key of the\nhost being run from configured on the bastion host.\u003c/em\u003e\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUsage\u003c/h3\u003e\u003ca id=\"user-content-usage\" class=\"anchor\" aria-label=\"Permalink: Usage\" href=\"#usage\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTo get usage instructions run the script without any arguments\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"mm\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003emm\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Usage: [command] [name]\n 1: The command to perform on the tunnel (eg. start/stop/restart/status)\n 2: (Optional) The name of the tunnel (eg. tunnel-name) or leave empty for all\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003eUsage: [command] [name]\n 1: The command to perform on the tunnel (eg. start/stop/restart/status)\n 2: (Optional) The name of the tunnel (eg. tunnel-name) or leave empty for all\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTunnels can either be directly referenced by their name (eg. example-tunnel-1) or you can leave it empty to apply the command to all tunnels.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eTunnels can also be referred to by any of their tags. If for example you want to start all tunnels which contain both the \u003cem\u003edev\u003c/em\u003e and \u003cem\u003eexample\u003c/em\u003e tags\nthen you can run 'mm start dev example'. Note that when starting by tag all tags provided must be present in the spreadsheet record.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExample\u003c/h4\u003e\u003ca id=\"user-content-example\" class=\"anchor\" aria-label=\"Permalink: Example\" href=\"#example\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIndividual\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"mm status example-tunnel-1\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003emm status example-tunnel-1\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Tunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev example | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003eTunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev example | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eAll\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"mm status\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003emm status\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Tunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \nexample-tunnel-2 | ci | 146.218.221.177 | 9090 | 8080 | ben@198.24.36.47 | Down \"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003eTunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \nexample-tunnel-2 | ci | 146.218.221.177 | 9090 | 8080 | ben@198.24.36.47 | Down \n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTag\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"mm status example\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003emm status example\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Tunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev example | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \nexample-tunnel-2 | ci example | 146.218.221.177 | 9090 | 8080 | ben@198.24.36.47 | Down \"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003eTunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev example | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \nexample-tunnel-2 | ci example | 146.218.221.177 | 9090 | 8080 | ben@198.24.36.47 | Down \n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"mm status dev\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003emm status dev\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Tunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev example | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode\u003eTunnel Name | Tags | IP | Local Port | Remote Port | Bastion | Status \n--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------\nexample-tunnel-1 | dev example | 12.151.112.202 | 3000 | 3000 | bill@136.62.46.55 | Down \n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003c/article\u003e","loaded":true,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":[{"level":1,"text":"Magic Mole","anchor":"magic-mole","htmlText":"Magic Mole"},{"level":3,"text":"Required Packages","anchor":"required-packages","htmlText":"Required Packages"},{"level":3,"text":"Installing","anchor":"installing","htmlText":"Installing"},{"level":3,"text":"Usage","anchor":"usage","htmlText":"Usage"},{"level":4,"text":"Example","anchor":"example","htmlText":"Example"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fgeodavies%2Fmagic-mole"}},{"displayName":"LICENSE","repoName":"magic-mole","refName":"master","path":"LICENSE","preferredFileType":"license","tabName":"MIT","richText":null,"loaded":false,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":null,"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fgeodavies%2Fmagic-mole"}}],"overviewFilesProcessingTime":0}},"appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-708ec8ade250.js","githubDevUrl":null,"enabled_features":{"copilot_workspace":true,"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}}

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Magic Mole

Bash network tunnel manager

Required Packages

  • grep
  • awk
  • sed
  • cat
  • autossh

Installing

First start by cloning this repository

cd <your-git-folder>
git clone https://github.com/geodavies/magic-mole.git

Next we need to configure which tunnels you want to use. This script will look for the file example-tunnels.csv for the configuration of the tunnels by default. This location can be changed by updating the location at the top of the script.

The example-tunnels.csv file inside this repository can be used as a starting point but you will likely want to move this somewhere more permanent in the long run. The below commands for your system will move the example-tunnels.c 7E74 sv file to your home directory and change the location in the script. If you already have a tunnels.csv file in your home directory it will be replaced, so make sure you back it up first or skip the second command.

Linux

cd magic-mole
cp example-tunnels.csv /home/$USER/tunnels.csv
sed -i 's/^input=.*$/input="\/home\/$USER\/tunnels.csv"/g' magic-mole.sh

MacOS

cd magic-mole
cp example-tunnels.csv /Users/$USER/tunnels.csv
sed -i '' 's/^input=.*$/input="\/Users\/$USER\/tunnels.csv"/g' magic-mole.sh

You can now execute the script directly from the git repository directory if you choose but you may want to create a symlink to the script so it can be executed from anywhere in the terminal.

sudo ln -s $PWD/magic-mole.sh /usr/local/bin/mm

The script can now be run from anywhere by using the command 'mm'

To have the tunnels start automatically on login, add the following to the bottom of ~/.profile:

mm start

Note this script is currently limited to only make connections to servers which already have the public key of the host being run from configured on the bastion host.

Usage

To get usage instructions run the script without any arguments

mm
Usage: [command] [name]
    1: The command to perform on the tunnel (eg. start/stop/restart/status)
    2: (Optional) The name of the tunnel (eg. tunnel-name) or leave empty for all

Tunnels can either be directly referenced by their name (eg. example-tunnel-1) or you can leave it empty to apply the command to all tunnels.

Tunnels can also be referred to by any of their tags. If for example you want to start all tunnels which contain both the dev and example tags then you can run 'mm start dev example'. Note that when starting by tag all tags provided must be present in the spreadsheet record.

Example

Individual

mm status example-tunnel-1
Tunnel Name               | Tags                           | IP              | Local Port      | Remote Port     | Bastion                   | Status 
--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------
example-tunnel-1          | dev example                    | 12.151.112.202  | 3000            | 3000            | bill@136.62.46.55         | Down           

All

mm status
Tunnel Name               | Tags                           | IP              | Local Port      | Remote Port     | Bastion                   | Status 
--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------
example-tunnel-1          | dev                            | 12.151.112.202  | 3000            | 3000            | bill@136.62.46.55         | Down   
example-tunnel-2          | ci                             | 146.218.221.177 | 9090            | 8080            | ben@198.24.36.47          | Down      

Tag

mm status example
Tunnel Name               | Tags                           | IP              | Local Port      | Remote Port     | Bastion                   | Status 
--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------
example-tunnel-1          | dev example                    | 12.151.112.202  | 3000            | 3000            | bill@136.62.46.55         | Down   
example-tunnel-2          | ci example                     | 146.218.221.177 | 9090            | 8080            | ben@198.24.36.47          | Down      
mm status dev
Tunnel Name               | Tags                           | IP              | Local Port      | Remote Port     | Bastion                   | Status 
--------------------------+--------------------------------+-----------------+-----------------+-----------------+---------------------------+----------
example-tunnel-1          | dev example                    | 12.151.112.202  | 3000            | 3000            | bill@136.62.46.55         | Down   

Releases

No releases published

Packages

No packages published

Languages

0