Skip to content

Commit

Permalink
use outliner's own sshkey and path, but system default
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyny committed Sep 5, 2019
1 parent e521b4f commit 512823d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 49 deletions.
33 changes: 9 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
```
Expand All @@ -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`
Expand All @@ -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`
Expand All @@ -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{
Expand All @@ -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/`
Expand All @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.4
v0.2.0
14 changes: 7 additions & 7 deletions pkg/deployer/ssh/consts/consts.go
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 4 additions & 9 deletions pkg/deployer/ssh/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
4 changes: 0 additions & 4 deletions pkg/util/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/util/prompter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 512823d

Please sign in to comment.