From 512823d637fd3823cde0fea2760cade118707284 Mon Sep 17 00:00:00 2001 From: jynychen Date: Thu, 5 Sep 2019 19:34:05 +0800 Subject: [PATCH] use outliner's own sshkey and path, but system default --- README.md | 33 +++++++++---------------------- VERSION | 2 +- pkg/deployer/ssh/consts/consts.go | 14 ++++++------- pkg/deployer/ssh/new.go | 13 ++++-------- pkg/util/printer.go | 4 ---- pkg/util/prompter.go | 4 ---- 6 files changed, 21 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index cb9bc6e..cc6f7de 100644 --- a/README.md +++ b/README.md @@ -24,17 +24,17 @@ Flags: Use "outliner [command] --help" for more information about a command. ``` + --- ## Contents - [Install or Download](#install-or-download) - [Mac OSX](#mac-osx) - - [Download binary from latest release](#download-binary-from-latest-release) + - [Download release from GitHub](#download-release-from-github) - [Setup](#setup) - [1. Get `API_TOKEN`](#1-get-api_token) - [2. Make a `.env` config file](#2-make-a-env-config-file) - - [3. Generate ssh key](#3-generate-ssh-key) - - [4. Ready to go](#4-ready-to-go) + - [3. Ready to go](#3-ready-to-go) - [Configurations](#configurations) - [config by `.env` file](#config-by-env-file) - [config by Environment Variables](#config-by-environment-variables) @@ -43,8 +43,6 @@ Use "outliner [command] --help" for more information about a command. - [Support Cloud(IaaS)](#support-cloudiaas) - [Development and Build](#development-and-build) ---- - ## Install or Download ### Mac OSX ``` @@ -61,8 +59,8 @@ $ brew install jyny/tap/outliner # apt isntall outliner ``` -### Download binary from latest release -[https://github.com/Jyny/outliner/releases/latest](https://github.com/Jyny/outliner/releases/latest) +### Download release from GitHub +Visit the [latest releases page](https://github.com/Jyny/outliner/releases/latest) ## Setup #### 1. Get `API_TOKEN` @@ -77,26 +75,15 @@ TOKEN_NAME_2 = TOKEN_VALUE_2 ... ``` -#### 3. Generate SSH key -outliner will generate ssh key, if Not found `id_rsa` and `id_rsa.pub` in `$HOME/.ssh/`. -run any command in outliner will do this after asking. -``` -$ outliner help -Continue to Generate New ssh key? (y/n) [y]: -``` -To generate key by yourself, see [Generating a new SSH key and adding it to the ssh-agent](https://help.github.com/en/enterprise/2.16/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) - -#### 4. Ready to go -##### * install by package manager like `homeberw` `pacman` `apt` etc. +#### 3. Ready to go +* install by package manager like `homeberw` `pacman` `apt` etc. 1. `$ outliner` -##### * install by download +* install by download 1. open terminal, go directory whrere you download outliner 2. maybe should add execute permission to binary (linux or mac) 3. `$ ./outliner_{OS}` ---- - ## Configurations ### config by `.env` file * `~/.outliner/.env` @@ -120,6 +107,7 @@ $ {TOKEN_NAME_1}={TOKEN_VALUE_1} outliner [command] | Digitalocean | | | Vultr | | + find full list in `pkg/cloud/{ProviderNmae}/activator.go` as below ``` var tokenNames = []string{ @@ -131,7 +119,6 @@ var tokenNames = []string{ ### Support configuration source outliner Support the following configuration source (list by Precedence order) - 1. with flag `-F, --file {FILE_PATH}` 2. Environment variables 3. `.env` file at `~/.outliner/` @@ -144,8 +131,6 @@ outliner Support the following configuration source (list by Precedence order) * Vultr (WIP) ... ---- - ## Development and Build #### 1. install package and build binary ``` diff --git a/VERSION b/VERSION index 8c43fb4..1474d00 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.1.4 +v0.2.0 diff --git a/pkg/deployer/ssh/consts/consts.go b/pkg/deployer/ssh/consts/consts.go index c4430a9..da049cc 100644 --- a/pkg/deployer/ssh/consts/consts.go +++ b/pkg/deployer/ssh/consts/consts.go @@ -1,17 +1,17 @@ package consts +// VariableName for gen vfsdata +const VariableName = "Script" + // DeployScriptPath for gen vfsdata -const DeployScriptPath = "./script/" +const DeployScriptPath = "script" // ScriptName for gen vfsdata -const ScriptName = "./deploy.sh" - -// VariableName for gen vfsdata -const VariableName = "Script" +const ScriptName = "deploy.sh" // PackageName for gen vfsdata const PackageName = "ssh" // ssh key path -const SSHKeyPubPath = "/.ssh/id_rsa.pub" -const SSHKeyPvtPath = "/.ssh/id_rsa" +const SSHKeyPubPath = ".outliner/sshkey.pub" +const SSHKeyPvtPath = ".outliner/sshkey" diff --git a/pkg/deployer/ssh/new.go b/pkg/deployer/ssh/new.go index db2fb42..941b4e1 100644 --- a/pkg/deployer/ssh/new.go +++ b/pkg/deployer/ssh/new.go @@ -15,7 +15,6 @@ import ( "github.com/jyny/outliner/pkg/deployer/ssh/consts" ol "github.com/jyny/outliner/pkg/outliner" - "github.com/jyny/outliner/pkg/util" ) func NewAgent() ol.Agent { @@ -49,14 +48,10 @@ func NewAgent() ol.Agent { } func genNewCredential() (pub string, pvt string) { - if !util.ContinueKeyGen() { - util.PrintByeNoKey() - os.Exit(1) - } u, _ := user.Current() savePrivateFileTo := filepath.Join(u.HomeDir, consts.SSHKeyPvtPath) savePublicFileTo := filepath.Join(u.HomeDir, consts.SSHKeyPubPath) - os.MkdirAll(filepath.Join(u.HomeDir, "/.ssh/"), os.ModePerm) + os.MkdirAll(filepath.Join(u.HomeDir, "/.outliner/"), os.ModePerm) bitSize := 4096 privateKey, err := generatePrivateKey(bitSize) @@ -97,7 +92,7 @@ func generatePrivateKey(bitSize int) (*rsa.PrivateKey, error) { return nil, err } - log.Println("[Generating] Private Key generated") + log.Println("[Initializing] Private Key generated") return privateKey, nil } @@ -129,7 +124,7 @@ func generatePublicKey(privatekey *rsa.PublicKey) ([]byte, error) { pubKeyBytes := ssh.MarshalAuthorizedKey(publicRsaKey) - log.Println("[Generating] Public key generated") + log.Println("[Initializing] Public key generated") return pubKeyBytes, nil } @@ -140,6 +135,6 @@ func writeKeyToFile(keyBytes []byte, saveFileTo string) error { return err } - log.Printf("[Generating] Key saved to: %s", saveFileTo) + log.Printf("[Initializing] Key saved to: %s", saveFileTo) return nil } diff --git a/pkg/util/printer.go b/pkg/util/printer.go index cca7dfc..ea3f9f2 100644 --- a/pkg/util/printer.go +++ b/pkg/util/printer.go @@ -137,10 +137,6 @@ func PrintAPICertJSON(in ol.APICert) { fmt.Println() } -func PrintByeNoKey() { - fmt.Println("Comback when your ssh key Ready") -} - func PrintCreateInstanceStart() { log.Println("[Creating Server]") } diff --git a/pkg/util/prompter.go b/pkg/util/prompter.go index bd71ab6..ef4dd7c 100644 --- a/pkg/util/prompter.go +++ b/pkg/util/prompter.go @@ -13,7 +13,3 @@ func ContinueInteractive() bool { fmt.Println("This is same as `./outliner deploy -i {SERVER_IP}`.") return prompter.YN("Do you want to continue to Auto Deploying", true) } - -func ContinueKeyGen() bool { - return prompter.YN("Continue to Generate New ssh key?", true) -}