Compare commits

...

237 Commits

Author SHA1 Message Date
Bo-Yi Wu c66c78f88f fix: lint error 2023-02-27 13:24:12 +08:00
Bo-Yi Wu 9723eea384 chore(CI): build docker image with multiple platform 2023-02-27 11:56:42 +08:00
dependabot[bot] 14ec2704bd chore(deps): bump github.com/urfave/cli/v2 from 2.24.3 to 2.24.4 (#156)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-23 13:15:47 +08:00
dependabot[bot] a1482e89a3 chore(deps): bump docker/build-push-action from 3 to 4 (#154)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-12 14:26:12 +08:00
Bo-Yi.Wu 9bf9ed00a4 chore(deps): upgrade go module
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-02-12 09:36:06 +08:00
Bo-Yi Wu 6bc14e020b chore(deps): upgrade go package 2023-02-03 17:22:02 +08:00
Bo-Yi Wu c309cf901d chore(command): support windows (#153) 2023-02-03 17:12:57 +08:00
Bo-Yi Wu 4c5df18366 chore(deps): upgrade action package 2023-02-02 13:43:54 +08:00
Bo-Yi Wu 5ec7c1ddf8 chore(deps): upgrade go package 2023-02-02 13:42:33 +08:00
Bo-Yi Wu 1c9314ed83 chore(CI): latest tag for linux and amd64 2023-01-03 10:33:55 +08:00
Bo-Yi.Wu 5672c1219f chore(CI): add strategy in docker build
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-01-01 15:16:45 +08:00
Bo-Yi.Wu 9d29c82de6 docs: add new badge
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:31:02 +08:00
Bo-Yi.Wu 1f8d333b42 chore(CI): add hadolint config
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:28:29 +08:00
Bo-Yi.Wu 50338d5bb1 chore(deps): update
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:16:31 +08:00
teutates 6d8c114979 feat(tar): add unlink-first flag (#141) 2022-12-29 21:15:21 +08:00
Bo-Yi.Wu c5c8b4021f chore(cli): add alias
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:13:47 +08:00
Bo-Yi.Wu 4a81a55a53 chore(lint): fix warning.
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:10:16 +08:00
Bo-Yi.Wu 9aef844da2 chore(CI): remove drone config
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:08:06 +08:00
Bo-Yi.Wu 6a4996cd63 chore(CI): update makefile
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-12-29 21:05:12 +08:00
Bo-Yi Wu 5053fc6aee chore(CI): migrate to GitHub Actions 2022-12-29 16:08:32 +08:00
Bo-Yi Wu 55cde9a13c fix: missing installed version 2022-06-15 21:51:42 +08:00
Bo-Yi Wu 7a31e10541 chore(go1.18): build tag 2022-06-15 15:29:09 +08:00
Bo-Yi Wu 8f4c7fa15b fix(ssh): OpenSSH 8.8+ RSA keys incompatibility (#136) 2022-06-15 15:28:13 +08:00
Bo-Yi Wu 8ed049422b chore(binary): unsupported GOOS/GOARCH pair darwin/386
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-10-23 18:43:22 +08:00
Bo-Yi Wu 731b24356e chore(lint): check removeAllDestFile
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-10-23 18:30:17 +08:00
Bo-Yi Wu 2d05265e3d chore(deploy): disbale testing
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-10-23 18:28:09 +08:00
Bo-Yi Wu 6ddf21aca4 chore(action): wrong variable name
see https://github.com/appleboy/scp-action/issues/30

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-10-23 18:23:13 +08:00
Bo-Yi Wu 8c5cba51c2 chore(go): upgrade go module
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-10-23 18:17:23 +08:00
Bo-Yi Wu 1b33947d29 chore: upgrade to go.16
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2021-06-18 08:52:35 +08:00
Bo-Yi Wu 35f7b2f6af chore: upgrade to go1.15
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-09-25 22:13:34 +08:00
Bo-Yi Wu f0867af189 chore: remove auto load .env file
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-06-15 15:55:32 +08:00
Bo-Yi Wu 4457897da5 chore: Support UseInsecureCipher (#115) 2020-05-24 14:17:43 +08:00
Bo-Yi Wu 6d6124e8d8 docs: add fingerprint 2020-05-21 23:13:26 +08:00
Bo-Yi Wu f4fff01bdb chore: missing Ciphers in removeAllDestFile 2020-05-21 23:09:53 +08:00
Bo-Yi Wu ac8ff855ae chore: update ssh server 2020-05-21 23:09:10 +08:00
Bo-Yi Wu 2ff51f00ff chore: support Fingerprint (#114) 2020-05-21 23:08:17 +08:00
Bo-Yi Wu b0f9b5b277 remove load env file from urfave/cli
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-05 09:36:22 +08:00
Bo-Yi Wu 457861ab2a chore(ssh): support Ciphers
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-05-04 10:27:02 +08:00
techknowlogick 1996e5d780 Add option to use file for host info (#113) 2020-04-29 14:22:30 +08:00
Bo-Yi Wu c75daae1f3 upgrade go version
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-04-16 15:29:15 +08:00
Bo-Yi Wu 72e6ea15b6 upgrade easyssh-proxy
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-04-16 15:28:58 +08:00
Bo-Yi Wu bad565d475 update success message format.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-27 09:53:36 +08:00
Bo-Yi Wu 8216bd8fb8 update to go 1.14
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-27 09:51:12 +08:00
Daniel Bingham 3d36432240 Fix typo in EnvVars for ssh-passphrase (#109) 2020-02-27 08:58:49 +08:00
Bo-Yi Wu 2fcaffcac8 docs: update passphrase variable
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-07 13:27:23 +08:00
Bo-Yi Wu c1e3242f53 update module
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-07 13:24:23 +08:00
Bo-Yi Wu 8e4a3f5e0c chore(makefile): remove GOPACKAGE variable 2020-02-01 00:41:34 +08:00
Bo-Yi Wu fe231a1c43 docs: add passphrase 2020-01-20 22:37:45 +08:00
Bo-Yi Wu 177625c6e7 chore: support passphrase (#107)
* chore: support passphrase
2020-01-20 22:34:16 +08:00
Bo-Yi Wu bb6466e8d9 chore: upgrade easyssh-proxy to v1.3.0 2020-01-19 23:40:00 +08:00
Bo-Yi Wu e5eae442c3 chore: update urfave/cli to v2 2020-01-19 23:38:47 +08:00
Bo-Yi Wu b73ec894ab chore: update default timeout to 10 minutes 2019-11-30 23:08:26 +08:00
Bo-Yi Wu 05eba8f809 docs(install): Add export GO111MODULE=on 2019-11-12 10:34:51 +08:00
Bo-Yi Wu a2493062f7 upgrade go module
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-12 10:11:21 +08:00
Bo-Yi Wu b2b346a0ca update example
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-04 14:11:57 +08:00
Bo-Yi Wu 9d8f5ac419 update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-04 13:43:54 +08:00
Bo-Yi Wu 5d93e7b8ab docs: update diff format 2019-10-18 22:40:46 +08:00
Bo-Yi Wu bf812f8e29 update docs
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-10-14 23:34:52 +08:00
Bo-Yi Wu 8814cfe72c docs: update drone 2019-10-14 23:33:18 +08:00
Bo-Yi Wu 954e0069e6 docs: update readme 2019-10-10 01:25:32 +08:00
Bo-Yi Wu 03524ed8bd docs: update to drone 1.0 format. 2019-09-29 02:01:24 +08:00
Bo-Yi Wu 531df19c8c docs: update drone docs. 2019-09-28 21:36:07 +08:00
Bo-Yi Wu df8214b645 chore: remove microbadge url 2019-09-28 17:33:25 +08:00
Bo-Yi Wu c85ca1ffd2 feat(tar): add Overwrite flag (#102)
* feat(tar): add Overwrite flag

* chore: remove

* chore: output

* chore: output
2019-09-28 16:59:01 +08:00
Ivo Nunes 933b45bc15 Add variable to set temporary tar upload path (#100) 2019-09-28 16:36:05 +08:00
Bo-Yi Wu 15344d67ae fix strip-components
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 16:30:07 +08:00
Bo-Yi Wu cf9e6f260d chore: debug command 2019-09-28 14:52:31 +08:00
Bo-Yi Wu cfa325a8c4 refactor: Add args command 2019-09-28 14:40:28 +08:00
Bo-Yi Wu c8dbddab25 chore: support -arch= 2019-09-28 14:14:15 +08:00
Bo-Yi Wu 1b27d28b27 chore: upgrade package 2019-09-28 12:52:08 +08:00
Bo-Yi Wu 8a0b0f3c0c chore(GitHub): support actions parameter. 2019-09-28 10:30:15 +08:00
Bo-Yi Wu ec489106f9 chore: upgrade to go1.13 2019-09-28 10:04:29 +08:00
Bo-Yi Wu 9ed20ee32d docs: fix markdown lint 2019-09-28 09:59:58 +08:00
Bo-Yi Wu 2aee5a3df1 docs: update 2019-08-03 23:51:16 +08:00
Bo-Yi Wu bc633e27cf docs: fix markdown lint 2019-08-03 18:55:27 +08:00
Bo-Yi Wu 9dad691d4f docs: update example 2019-08-03 18:55:02 +08:00
Bo-Yi Wu 66579b6dae chore: add proxy variable 2019-05-11 19:51:39 +08:00
Bo-Yi Wu 06609f35cf add key variable
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-05-11 16:50:50 +08:00
Bo-Yi Wu c9771cce78 chore: add variable 2019-05-11 16:49:20 +08:00
Bo-Yi Wu 6088f7da5a chore: update build tag 2019-05-11 16:34:36 +08:00
Bo-Yi Wu 6de8f74170 docs: add ignore list example. 2019-05-11 14:34:40 +08:00
Bo-Yi Wu bb63d55f89 Update README.md 2019-05-09 14:08:52 +08:00
Bo-Yi Wu da44b071c4 chore: switch finished to struct{} for zero allocate (#96) 2019-03-30 07:26:53 +08:00
Bo-Yi Wu a7eddc4b11 docs: fix setting
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-11 17:22:33 +08:00
Bo-Yi Wu 813faf56be chore: remove build number 2019-03-10 23:43:06 +08:00
Bo-Yi Wu 4117d2ca30 fix: trigger build fail if error (#94)
fix #93
2019-03-10 23:41:21 +08:00
Bo-Yi Wu 15bd1a11e4 chore: change command timeout flag (#92)
* chore: change command timeout flag

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* docs: update setting

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* doc: update readme.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-07 13:56:40 +08:00
Bo-Yi Wu be0d85245a update go module
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-07 11:15:54 +08:00
Bo-Yi Wu 9cc27c6724 refactor: err check
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-06 11:05:15 +08:00
Bo-Yi Wu b36ffb0d5d fix: add empty line 2019-03-04 21:46:05 +08:00
Bo-Yi Wu ca7485443c chore(docker): replace ADD with COPY 2019-03-04 21:43:11 +08:00
Bo-Yi Wu f8a64791a4 chore: add lint check
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-03-04 16:11:12 +08:00
Bo-Yi Wu fe8e5e3483 fix: remove check username exist. (#91) 2019-03-03 07:16:57 +08:00
Bo-Yi Wu 2344618287 docs: update badge 2019-03-03 00:28:21 +08:00
Bo-Yi Wu 24926998c1 fix: binary name 2019-03-03 00:09:58 +08:00
Bo-Yi Wu a82a76903c fix: ssh config 2019-03-03 00:07:55 +08:00
Bo-Yi Wu 8e1c446a58 chore: update testing. 2019-03-02 23:53:27 +08:00
Bo-Yi Wu a2e6a07e44 feat: switch from govender to module. 2019-03-02 23:52:35 +08:00
Bo-Yi Wu bc7d0d7a7a docs: update 2019-01-27 11:34:27 +08:00
Bo-Yi Wu 26223d7b71 docs: Example ignore list configuration 2019-01-18 23:17:23 +08:00
Bo-Yi Wu b3f09b7592 refactor(lint): replace tool 2019-01-18 22:58:17 +08:00
Bo-Yi Wu 75d2ee1e10 fix missing exclude files (#88)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-01-18 16:40:50 +08:00
Bo-Yi Wu 699675c8fa add debug command. (#87)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-01-18 16:06:22 +08:00
Bo-Yi Wu d921289474 feat(ignore): support ignore list (#86)
fix #85
2019-01-18 15:12:36 +08:00
Bo-Yi Wu 4f7d31bd86 fix: missing tar config (#83) 2018-11-05 15:22:19 +08:00
natlibfi-arlehiko d798a8cc75 Add TarExec parameter (#82)
Add TarExec parameter to provide an alternative tar-command (E.g. On old non-Linux systems it may be necessary to use gtar).
2018-11-05 15:11:00 +08:00
Bo-Yi Wu 147005589b support user key. 2018-11-05 09:05:34 +08:00
Bo-Yi Wu 7fa57c038a add error action preference
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2018-06-27 14:18:19 +08:00
Bo-Yi Wu e6e048f198 fix: Provide a password using STDIN 2018-06-27 14:16:43 +08:00
Bo-Yi Wu 8096419bd2 chore: upgrade to 1.10 golang version. 2018-04-06 10:18:08 +08:00
Bo-Yi Wu 985badff42 mark arm and arm64 docker
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-12-22 13:51:15 +08:00
Bo-Yi Wu f68e09cf01 fix: arm32 image 2017-12-22 13:47:14 +08:00
Bo-Yi Wu 9150f669c9 fix: missing binary 2017-12-22 13:42:29 +08:00
Bo-Yi Wu ceb2b47958 feat(docker): suport arm arm64 image 2017-12-22 12:43:46 +08:00
Bo-Yi Wu acc220475c fix: Add build number. 2017-12-22 11:41:04 +08:00
Bo-Yi Wu 43d4f0d781 fix(error): show error log. 2017-12-22 11:38:13 +08:00
Bo-Yi Wu 357e2db0ff fix: update example. 2017-12-22 11:30:53 +08:00
Bo-Yi Wu 7764e754fe feat(docker): support windows build 2017-12-22 11:26:07 +08:00
Bo-Yi Wu 5bf5231d41 remove arm alpine arm64 i386 image.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-12-22 11:24:11 +08:00
Bo-Yi Wu 0261361be4 fix: stat /tmp: no such file or directory 2017-12-22 11:09:29 +08:00
Bo-Yi Wu f410f5e6ca chore(git): add release folder to ignore list. 2017-12-22 10:58:32 +08:00
Bo-Yi Wu e8f0048a45 refactor(notify): change fb to discord. 2017-12-22 10:55:01 +08:00
Bo-Yi Wu 41ace25862 feat(docker): suport arm arm64 alpine i386 image (#77) 2017-12-22 10:52:42 +08:00
Bo-Yi Wu 9c958f8637 docs(drone): add secret section 2017-12-18 09:45:38 +08:00
Bo-Yi Wu 9352413b30 add maintainer label.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-10-05 11:35:16 +08:00
Bo-Yi Wu f22cd46f46 Add some ssh env (#73) 2017-07-28 09:03:38 +08:00
Bo-Yi Wu 2cc69e2c03 update notify condition.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-06-24 22:55:10 +08:00
Bo-Yi Wu 637dcaaccc update drone ci website link.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-06-10 11:16:22 +08:00
Bo-Yi Wu 7c9b1d8b79 refactor: update gofmt check command. (#71) 2017-05-22 11:09:42 +08:00
Bo-Yi Wu 7a88a784b2 refactor: hide domain info if only single domain in drone setting. (#70) 2017-05-15 17:16:21 +08:00
Bo-Yi Wu 13e681cc3b refactor: wait group 2017-05-15 17:08:19 +08:00
Bo-Yi Wu a363fa22bf upgrade easyssh-proxy (#69)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-14 18:28:13 +08:00
Bo-Yi Wu 2ee4b54624 upgrade drone config. (#68)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-14 18:22:06 +08:00
Bo-Yi Wu a2708638cf [ci skip] update docs.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-05-01 08:55:15 +08:00
Bo-Yi Wu 35c2f7a14c feat: support strip components flag for tar command (#65)
Remove the specified number of leading path elements.
2017-04-30 23:18:22 +08:00
Bo-Yi Wu 8dba1e8e32 fix: quick fix. (#63) 2017-04-21 19:34:32 +08:00
Bo-Yi Wu 049263e847 refactor: show errors if set password and key at the same time (#62) 2017-04-21 16:38:43 +08:00
Bo-Yi Wu 88f5a95f3e add scp error message (#60)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-04-20 14:59:09 +08:00
Bo-Yi Wu 7bdc9fc05e refactor: HostKeyCallback is the function type used for verifying server (#59)
* refactor: HostKeyCallback is the function type used for verifying server

* update ssh package.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-04-15 20:45:16 +08:00
Bo-Yi Wu 3b2dbe955b remove drone sig file. (#57)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-04-14 09:19:05 +08:00
Bo-Yi Wu 464f0edc7e feat: add fmt check command. (#56) 2017-04-02 19:59:50 +08:00
Bo-Yi Wu 6aa6653378 update testing for remove single dest file. (#55)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-03-25 23:05:13 +08:00
Bo-Yi Wu d326bfe5a4 feat: update easyssh-proxy to 1.1.1 (#54) 2017-03-25 22:46:03 +08:00
Bo-Yi Wu 2ebb608269 feat: add color (#53) 2017-03-25 20:35:10 +08:00
Bo-Yi Wu f223505d46 add copy error handle. (#52) 2017-03-25 20:19:07 +08:00
Bo-Yi Wu b1ca6d49a2 feat: remove temp file if encounter errors. (#51) 2017-03-25 17:23:03 +08:00
Bo-Yi Wu c612c8c5c0 [ci skip] add proxy config docs
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-03-23 13:48:14 +08:00
Bo-Yi Wu e8dfaea058 Update README.md 2017-03-10 17:11:22 +08:00
Bo-Yi Wu 3121cb2aaa [ci skip] docs: add ProxyCommand docs. (#49)
* docs: add ProxyCommand docs.
2017-03-07 11:12:49 +08:00
Bo-Yi Wu 72c123f390 feat: Support scp files from proxy command. (#47)
* feat: Support scp files from proxy command.
2017-03-06 14:43:52 +08:00
Bo-Yi Wu 04c639cfa8 feat: upgrade to easyssh-proxy package. (#45)
* feat: upgrade to easyssh-proxy package.

* add command timeout flag
* upgrade easyssh to easyssh-proxy
2017-03-06 12:35:57 +08:00
Bo-Yi Wu ef521d1e98 refactor: hash is a much faster shell-builtin alternative to which. (#43) 2017-02-27 22:08:26 +08:00
Bo-Yi Wu 496e23a7e9 feat: improve coverage for easyssh (#42)
* feat: improve coverage for easyssh
2017-02-14 15:23:41 +08:00
Bo-Yi Wu 3e7ff1f928 refactor: remove travis 2017-02-14 12:34:53 +08:00
Bo-Yi Wu 6179afcde8 test: improve code coverage for easyssh. (#39)
* test: improve code coverage.

* feat: test password
2017-02-14 12:33:19 +08:00
Bo-Yi Wu 4f2e0c2096 refactor: remove travis (#41) 2017-02-14 12:30:51 +08:00
Bo-Yi Wu e2b890d217 remove glide config.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-02-14 09:49:48 +08:00
Bo-Yi Wu cdfa646abf docs: fix diff format. 2017-02-13 12:00:35 +08:00
Bo-Yi Wu ed37a75097 docs: [ci skip] update docs 2017-02-13 11:17:05 +08:00
Bo-Yi Wu baa413d348 feat: support wildcard file list. (#37)
* feat: support wildcard file list.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-02-13 11:09:14 +08:00
Bo-Yi Wu 79f352a5fa refactor: remove glide from drone config (#36)
* refactor: remove glide from drone config
2017-02-13 10:29:42 +08:00
Bo-Yi Wu 9787fcfb60 refactor: add vendor folder. (#34)
* refactor: add vendor folder.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-02-12 17:51:17 +08:00
Bo-Yi Wu ae6b001406 docs: [ci skip] add drone plugin document link. 2017-02-08 10:28:21 +08:00
Bo-Yi Wu 0d84586fb1 test: add easyssh scp and ssh command testing. (#29) 2017-02-04 20:50:51 +08:00
Bo-Yi Wu d673dc3a68 fix: [ci skip] drone link. 2017-02-04 18:39:22 +08:00
Bo-Yi Wu 1f05c75ba3 docs: [ci skip] update doc 2017-02-04 18:38:42 +08:00
Bo-Yi Wu 6472931282 refactor: add ssh-server command. (#28) 2017-02-04 17:35:31 +08:00
Bo-Yi Wu bb6e686f9a feat: initial easyssh testing. (#27) 2017-02-04 17:21:42 +08:00
Bo-Yi Wu 3911edcd30 docs: [ci skip] add timeout description 2017-01-31 21:17:09 +08:00
Bo-Yi Wu 212aa456c6 fix: duplicate of -t flag 2017-01-30 16:31:38 +08:00
Bo-Yi Wu 87fcf060aa refactor: update ssh host using JoinHostPort 2017-01-30 00:46:53 +08:00
Bo-Yi Wu 57d83dcfe0 feat: Add timeout flag. (#26) 2017-01-29 13:56:23 +08:00
Bo-Yi Wu e5ead0fb9c feat: Add unconvert command 2017-01-28 11:41:52 +08:00
Bo-Yi Wu 4e0a131533 docs: [ci skip] remove secret section. 2017-01-20 15:03:14 +08:00
Bo-Yi Wu 2704d9d275 fix: Enforce custom LDFLAGS within makefile 2017-01-17 10:37:41 +08:00
Bo-Yi Wu e9832010f8 fix: Clone tags within drone for proper version generation 2017-01-15 12:06:47 +08:00
Bo-Yi Wu 28824dfd1a fix: golint error: missing ',' before newline 2017-01-07 11:33:51 +08:00
Bo-Yi Wu 22b6f8b9b4 docs: [ci skip] update document. 2017-01-06 14:02:28 +08:00
Bo-Yi Wu 1d806cc9ed docs: [ci skip] add drone docs link. 2017-01-06 12:19:46 +08:00
Bo-Yi Wu dd049e69b9 docs: [ci skip] add drone docs. (#23) 2017-01-06 12:07:21 +08:00
Bo-Yi Wu 61940b4c0e docs: [ci skip] update example code. 2017-01-04 16:37:41 +08:00
Bo-Yi Wu f20fc0b114 fix: GOMAXPROCS set to the number of cores available in 1.5 2017-01-04 16:10:33 +08:00
Bo-Yi Wu ed00c6ef85 docs: [ci skip] update doc 2017-01-04 10:47:40 +08:00
Bo-Yi Wu cc822cd578 update commmand line.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-01-04 10:36:04 +08:00
Bo-Yi Wu 77dbb22aed test: support windows testing. (#21) 2017-01-03 16:59:00 +08:00
Bo-Yi Wu b69d758088 feat: support windows (#20) 2017-01-03 16:22:06 +08:00
Bo-Yi Wu 65e19227c4 update readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-01-02 21:26:26 +08:00
Bo-Yi Wu df18b64cb4 fix fmt command.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-31 13:30:36 +08:00
Bo-Yi Wu f987106211 support ssh agent.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 21:50:39 +08:00
Bo-Yi Wu eddd7a9661 [ci skip] remove windows support.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 15:12:36 +08:00
Bo-Yi Wu 1355c4edc1 [ci skip] add badge.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 13:36:39 +08:00
Bo-Yi Wu 2eb54a15ca remove create root .ssh folder.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 13:12:10 +08:00
Bo-Yi Wu 42540b5d45 Merge pull request #19 from appleboy/ssh
Add ssh testing.
2016-12-30 12:43:49 +08:00
Bo-Yi Wu 5f176416d7 add ssh server for alpine.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 12:38:44 +08:00
Bo-Yi Wu 6c2d597d31 update drone setting
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 11:33:57 +08:00
Bo-Yi Wu 9aa3cdb828 update travis testing.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 11:13:22 +08:00
Bo-Yi Wu 392c7c90e3 Add ssh testing.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-30 10:44:49 +08:00
Bo-Yi Wu a0c61bbd03 update readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-29 07:17:55 +08:00
Bo-Yi Wu 5a6851415d Support key path.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-29 07:16:38 +08:00
Bo-Yi Wu e4f3a180c8 add random string.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 15:56:17 +08:00
Bo-Yi Wu 9dbfdad07c remove ENV.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 14:58:51 +08:00
Bo-Yi Wu debd2db692 hide codecov token
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:54:13 +08:00
Bo-Yi Wu 5bd128025d add cache and fix repo name
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:52:36 +08:00
Bo-Yi Wu d3b4925aff add drone sign file.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:48:59 +08:00
Bo-Yi Wu 291c006b5c fix docker image name
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:45:05 +08:00
Bo-Yi Wu dd7f593c06 fix makefile.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:43:26 +08:00
Bo-Yi Wu 9559a5b600 Merge pull request #17 from appleboy/tool
Add release tool
2016-12-28 11:41:00 +08:00
Bo-Yi Wu 974cd420af add some env.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:27:23 +08:00
Bo-Yi Wu d31fe06287 add badge.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:25:35 +08:00
Bo-Yi Wu 9384d1261d add coverage command.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:23:06 +08:00
Bo-Yi Wu 43037f5cef using go latest version.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:15:49 +08:00
Bo-Yi Wu f43d0a817e remove docker from travis.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:14:56 +08:00
Bo-Yi Wu 6cb6510fed fix path.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:11:15 +08:00
Bo-Yi Wu da5dda1f0d update glide version.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:09:43 +08:00
Bo-Yi Wu 4fc0ebcd98 update tool
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-28 11:02:31 +08:00
Bo-Yi Wu e3418f8441 Merge pull request #15 from appleboy/sync
Support golang routines
2016-12-27 14:38:42 +08:00
Bo-Yi Wu d5baf6186d update readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-27 14:33:56 +08:00
Bo-Yi Wu f5d5e54a57 Support routines.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-27 14:33:21 +08:00
Bo-Yi Wu 031c1e4801 Merge pull request #13 from appleboy/multiple_target
support multiple target
2016-12-19 16:42:13 +08:00
Bo-Yi Wu 1bae57a838 update readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-19 16:30:41 +08:00
Bo-Yi Wu 91ef54d3d6 Support multiple target.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-19 16:29:38 +08:00
Bo-Yi Wu bfb8c6795c Merge pull request #12 from appleboy/multiple_host
support multiple host
2016-12-19 15:28:46 +08:00
Bo-Yi Wu 339a0d497f fix testing
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-19 15:23:16 +08:00
Bo-Yi Wu cc1520024e support multiple host
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-19 15:13:11 +08:00
Bo-Yi Wu 455b6dd7ae update check go version.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-05 11:19:52 +08:00
Bo-Yi Wu f12fc6e476 update golang testing to 1.6.4 and 1.7.4
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-05 11:12:08 +08:00
Bo-Yi Wu 807dff2951 update readme.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-05 11:10:21 +08:00
Bo-Yi Wu 8171197bad Merge pull request #10 from appleboy/rm
Support rm flag
2016-12-05 11:08:03 +08:00
Bo-Yi Wu 3277383d4f update readme
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-05 11:06:10 +08:00
Bo-Yi Wu 2bb7d842f2 support rm flag
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-12-05 11:04:11 +08:00
Bo-Yi Wu 6e7710e445 Merge pull request #6 from appleboy/bug
fix tar multiple folder or file.
2016-11-29 15:30:07 +08:00
Bo-Yi Wu 658203c26d fix tar multiple folder or file.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-11-29 15:29:03 +08:00
Bo-Yi Wu 7cd8855a53 remove --rm flag 2016-11-28 16:37:33 +08:00
Bo-Yi Wu 42851ed07b Merge pull request #4 from appleboy/cli
Support load configuration from files.
2016-11-21 11:19:36 +08:00
Bo-Yi Wu 7b90afbf37 Support load configuration from files.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-11-21 11:10:20 +08:00
Bo-Yi Wu 21d349362b update Version comment.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-11-19 22:34:54 +08:00
Bo-Yi Wu 7dfdbbde89 add version command.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2016-11-19 21:21:37 +08:00
40 changed files with 2502 additions and 569 deletions
-42
View File
@@ -1,42 +0,0 @@
# unifying the coding style for different editors and IDEs => editorconfig.org
; indicate this is the root of the project
root = true
###########################################################
; common
###########################################################
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
###########################################################
; make
###########################################################
[Makefile]
indent_style = tab
[makefile]
indent_style = tab
###########################################################
; markdown
###########################################################
[*.md]
trim_trailing_whitespace = false
###########################################################
; golang
###########################################################
[*.go]
indent_style = tab
+13
View File
@@ -0,0 +1,13 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://www.paypal.me/appleboy46']
+10
View File
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
+24
View File
@@ -0,0 +1,24 @@
name: Release Binary
on:
push:
branches:
- master
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
container: techknowlogick/xgo:go-1.19.x
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# - name: Release binary
# run: |
# ls -al
# make release
+54
View File
@@ -0,0 +1,54 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '41 23 * * 6'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+77
View File
@@ -0,0 +1,77 @@
name: Docker Image
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- 'master'
jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: '^1'
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build binary
run : |
make build_linux_amd64
make build_linux_arm
make build_linux_arm64
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
id: docker-meta
uses: docker/metadata-action@v4
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm,linux/arm64
file: docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
+35
View File
@@ -0,0 +1,35 @@
name: Goreleaser
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Setup go
uses: actions/setup-go@v3
with:
go-version: '^1'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+45
View File
@@ -0,0 +1,45 @@
name: Lint and Testing
on:
push:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: '^1'
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --verbose
- uses: hadolint/hadolint-action@v3.1.0
name: hadolint for Dockerfile
with:
dockerfile: docker/Dockerfile
testing:
runs-on: ubuntu-latest
container: golang:1.19-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: setup sshd server
run: |
apk add git make curl perl bash build-base zlib-dev ucl-dev
make ssh-server
- name: testing
run: |
make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
+4 -1
View File
@@ -22,6 +22,9 @@ _testmain.go
*.exe
*.test
*.prof
vendor
drone-scp
coverage.txt
.env
dist
.cover
release
+2
View File
@@ -0,0 +1,2 @@
ignored:
- DL3018
-53
View File
@@ -1,53 +0,0 @@
sudo: required
language: go
services:
- docker
go:
- 1.5.4
- 1.6.3
- 1.7.3
- tip
env:
global:
- DOCKER_CACHE_FILE=${HOME}/docker/cache.tar.gz
cache:
directories:
- vendor
- ${HOME}/.glide
- ${HOME}/docker
before_install:
- mkdir -p $GOPATH/bin
- curl https://glide.sh/get | sh
- if [ -f ${DOCKER_CACHE_FILE} ]; then gunzip -c ${DOCKER_CACHE_FILE} | docker load; fi
install:
- export GO15VENDOREXPERIMENT=1
- make install
script:
- make test
- make docker
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
mkdir -p $(dirname ${DOCKER_CACHE_FILE});
docker save $(docker history -q $TRAVIS_REPO_SLUG:latest | grep -v '<missing>') | gzip > ${DOCKER_CACHE_FILE};
fi
after_success:
# ignore main.go coverage
- sed -i '/main.go/d' coverage.txt
- bash <(curl -s https://codecov.io/bash) -f coverage.txt
# deploy from master
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_GO_VERSION" == "1.7.3" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
make docker_deploy tag=latest;
fi
# deploy from tag
- if [ "$TRAVIS_GO_VERSION" == "1.7.3" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
make docker_deploy tag=$TRAVIS_TAG;
fi
+297
View File
@@ -0,0 +1,297 @@
---
date: 2017-01-06T00:00:00+00:00
title: SCP
author: appleboy
tags: [ publish, ssh, scp ]
logo: term.svg
repo: appleboy/drone-scp
image: appleboy/drone-scp
---
The SCP plugin copy files and artifacts to target host machine via SSH. The below pipeline configuration demonstrates simple usage:
```yaml
- name: scp files
image: appleboy/drone-scp
settings:
host: example.com
username: foo
password: bar
port: 22
target: /var/www/deploy/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}
source: release.tar.gz
```
Example configuration with multiple source and target folder:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host: example.com
target:
+ - /home/deploy/web1
+ - /home/deploy/web2
source:
+ - release_1.tar.gz
+ - release_2.tar.gz
```
Example configuration with multiple host:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
- host: example.com
+ host:
+ - example1.com
+ - example2.com
target: /home/deploy/web
source: release.tar.gz
```
Example configuration with wildcard pattern of source list:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
target: /home/deploy/web
source:
- - release/backend.tar.gz
- - release/images.tar.gz
+ - release/*.tar.gz
```
Remove target folder before copy files and artifacts to target:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
target: /home/deploy/web
source: release.tar.gz
+ rm: true
```
Example for remove the specified number of leading path elements:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host: example.com
target: /home/deploy/web
source: dist/release.tar.gz
+ strip_components: 1
```
Example configuration using SSHProxyCommand:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
target: /home/deploy/web
source:
- release/*.tar.gz
+ proxy_host: 10.130.33.145
+ proxy_user: ubuntu
+ proxy_port: 22
+ proxy_password: 1234
```
Example configuration using password from secrets:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
user: ubuntu
port: 22
- password: 1234
+ password:
+ from_secret: ssh_password
target: /home/deploy/web
source:
- release/*.tar.gz
```
Example configuration using command timeout:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
user: ubuntu
password:
from_secret: ssh_password
port: 22
- command_timeout: 120
+ command_timeout: 2m
target: /home/deploy/web
source:
- release/*.tar.gz
```
Example configuration for ignore list:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
user: ubuntu
password:
from_secret: ssh_password
port: 22
command_timeout: 2m
target: /home/deploy/web
source:
+ - !release/README.md
- release/*
```
Example configuration for passphrase which protecting a private key:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
user: ubuntu
+ key:
+ from_secret: ssh_key
+ passphrase: 1234
port: 22
command_timeout: 2m
target: /home/deploy/web
source:
- release/*
```
## Parameter Reference
host
: target hostname or IP
port
: ssh port of target host
username
: account for target host user
password
: password for target host user
key
: plain text of user private key
passphrase
: The purpose of the passphrase is usually to encrypt the private key.
fingerprint
: fingerprint SHA256 of the host public key, default is to skip verification
target
: folder path of target host
source
: source lists you want to copy
rm
: remove target folder before copy files and artifacts
timeout
: Timeout is the maximum amount of time for the ssh connection to establish, default is 30 seconds.
command_timeout
: Command timeout is the maximum amount of time for the execute commands, default is 10 minutes.
strip_components
: remove the specified number of leading path elements
tar_tmp_path
: temporary path for tar file on the dest host
tar_exec
: alternative `tar` executable to on the dest host
overwrite
: use `--overwrite` flag with tar
proxy_host
: proxy hostname or IP
proxy_port
: ssh port of proxy host
proxy_username
: account for proxy host user
proxy_password
: password for proxy host user
proxy_key
: plain text of proxy private key
proxy_key_path
: key path of proxy private key
proxy_passphrase
: The purpose of the passphrase is usually to encrypt the private key.
proxy_fingerprint
: fingerprint SHA256 of the host public key, default is to skip verification
## Template Reference
repo.owner
: repository owner
repo.name
: repository name
build.status
: build status type enumeration, either `success` or `failure`
build.event
: build event type enumeration, one of `push`, `pull_request`, `tag`, `deployment`
build.number
: build number
build.commit
: git sha for current commit
build.branch
: git branch for current commit
build.tag
: git tag for current commit
build.ref
: git ref for current commit
build.author
: git author for current commit
build.link
: link the the build results in drone
-9
View File
@@ -1,9 +0,0 @@
FROM alpine:3.4
RUN apk update && \
apk add ca-certificates && \
rm -rf /var/cache/apk/*
ADD drone-scp /
ENTRYPOINT ["/drone-scp"]
-8
View File
@@ -1,8 +0,0 @@
FROM armhfbuild/alpine:3.4
RUN apk update && \
apk add ca-certificates && \
rm -rf /var/cache/apk/*
ADD drone-scp /bin/
ENTRYPOINT ["/bin/drone-scp"]
+146 -25
View File
@@ -1,8 +1,19 @@
.PHONY: install build test html update docker_build docker_image docker docker_deploy clean
DIST := dist
EXECUTABLE := drone-scp
GOFMT ?= gofumpt -l
DIST := dist
DIST_DIRS := $(DIST)/binaries $(DIST)/release
GO ?= go
SHASUM ?= shasum -a 256
GOFILES := $(shell find . -name "*.go" -type f)
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
XGO_VERSION := go-1.19.x
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
VERSION := $(shell git describe --tags || git rev-parse --short HEAD)
DEPLOY_ACCOUNT := "appleboy"
DEPLOY_IMAGE := "drone-scp"
LINUX_ARCHS ?= linux/amd64,linux/arm64
DARWIN_ARCHS ?= darwin-10.12/amd64,darwin-10.12/arm64
WINDOWS_ARCHS ?= windows/*
ifneq ($(shell uname), Darwin)
EXTLDFLAGS = -extldflags "-static" $(null)
@@ -10,36 +21,146 @@ else
EXTLDFLAGS =
endif
install:
glide install
ifeq ($(HAS_GO), GO)
GOPATH ?= $(shell $(GO) env GOPATH)
export PATH := $(GOPATH)/bin:$(PATH)
build:
go build -ldflags="$(EXTLDFLAGS)-s -w -X main.Version=$(VERSION)"
CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
endif
ifeq ($(OS), Windows_NT)
GOFLAGS := -v -buildmode=exe
EXECUTABLE ?= $(EXECUTABLE).exe
else ifeq ($(OS), Windows)
GOFLAGS := -v -buildmode=exe
EXECUTABLE ?= $(EXECUTABLE).exe
else
GOFLAGS := -v
EXECUTABLE ?= $(EXECUTABLE)
endif
ifneq ($(DRONE_TAG),)
VERSION ?= $(DRONE_TAG)
else
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
endif
TAGS ?=
LDFLAGS ?= -X 'main.Version=$(VERSION)'
all: build
fmt:
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) install mvdan.cc/gofumpt; \
fi
$(GOFMT) -w $(GOFILES)
vet:
$(GO) vet ./...
.PHONY: fmt-check
fmt-check:
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) install mvdan.cc/gofumpt; \
fi
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
test:
go test -v -coverprofile=coverage.txt
@$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
html:
go tool cover -html=coverage.txt
install: $(GOFILES)
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
update:
glide up
build: $(EXECUTABLE)
docker_build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags="-X main.Version=$(VERSION)"
$(EXECUTABLE): $(GOFILES)
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@
docker_image:
docker build --rm -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) .
build_linux_amd64:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE)
docker: docker_build docker_image
build_linux_i386:
CGO_ENABLED=0 GOOS=linux GOARCH=386 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/i386/$(DEPLOY_IMAGE)
docker_deploy:
ifeq ($(tag),)
@echo "Usage: make $@ tag=<tag>"
@exit 1
build_linux_arm64:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm64/$(DEPLOY_IMAGE)
build_linux_arm:
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE)
ssh-server:
adduser -h /home/drone-scp -s /bin/sh -D -S drone-scp
echo drone-scp:1234 | chpasswd
mkdir -p /home/drone-scp/.ssh
chmod 700 /home/drone-scp/.ssh
cat tests/.ssh/id_rsa.pub >> /home/drone-scp/.ssh/authorized_keys
cat tests/.ssh/test.pub >> /home/drone-scp/.ssh/authorized_keys
chmod 600 /home/drone-scp/.ssh/authorized_keys
chown -R drone-scp /home/drone-scp/.ssh
apk add --update openssh openrc
rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
./tests/entrypoint.sh /usr/sbin/sshd -D &
coverage:
sed -i '/main.go/d' coverage.txt
.PHONY: deps-backend
deps-backend:
$(GO) mod download
$(GO) install $(GXZ_PAGAGE)
$(GO) install $(XGO_PACKAGE)
.PHONY: release
release: release-linux release-darwin release-windows release-copy release-compress release-check
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: release-windows
release-windows: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(WINDOWS_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
ifeq ($(CI),true)
cp -r /build/* $(DIST)/binaries/
endif
docker tag $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):latest $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
docker push $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
.PHONY: release-linux
release-linux: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
ifeq ($(CI),true)
cp -r /build/* $(DIST)/binaries/
endif
.PHONY: release-darwin
release-darwin: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets '$(DARWIN_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
ifeq ($(CI),true)
cp -r /build/* $(DIST)/binaries/
endif
.PHONY: release-copy
release-copy: | $(DIST_DIRS)
cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
.PHONY: release-check
release-check: | $(DIST_DIRS)
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
.PHONY: release-compress
release-compress: | $(DIST_DIRS)
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PAGAGE) -k -9 $${file}; done;
clean:
rm -rf coverage.txt ${DEPLOY_IMAGE}
$(GO) clean -x -i ./...
rm -rf coverage.txt $(EXECUTABLE) $(DIST)
version:
@echo $(VERSION)
+233 -35
View File
@@ -1,63 +1,261 @@
# drone-scp
[![Build Status](https://travis-ci.org/appleboy/drone-scp.svg?branch=master)](https://travis-ci.org/appleboy/drone-scp) [![codecov](https://codecov.io/gh/appleboy/drone-scp/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-scp) [![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-scp)](https://goreportcard.com/report/github.com/appleboy/drone-scp)
[![GoDoc](https://godoc.org/github.com/appleboy/drone-scp?status.svg)](https://godoc.org/github.com/appleboy/drone-scp)
[![Lint and Testing](https://github.com/appleboy/drone-scp/actions/workflows/lint.yml/badge.svg)](https://github.com/appleboy/drone-scp/actions/workflows/lint.yml)
[![codecov](https://codecov.io/gh/appleboy/drone-scp/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-scp)
[![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-scp)](https://goreportcard.com/report/github.com/appleboy/drone-scp)
[![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-scp.svg)](https://hub.docker.com/r/appleboy/drone-scp/)
[Drone](https://github.com/drone/drone) plugin to copy files and artifacts via SSH.
Copy files and artifacts via SSH using a binary, docker or [Drone CI](http://docs.drone.io/).
## Build
## Feature
Build the binary with the following commands:
* [x] Support routines.
* [x] Support wildcard pattern on source list.
* [x] Support send files to multiple host.
* [x] Support send files to multiple target folder on host.
* [x] Support load ssh key from absolute path or raw body.
* [x] Support SSH ProxyCommand.
```
$ make build
```sh
+--------+ +----------+ +-----------+
| Laptop | <--> | Jumphost | <--> | FooServer |
+--------+ +----------+ +-----------+
OR
+--------+ +----------+ +-----------+
| Laptop | <--> | Firewall | <--> | FooServer |
+--------+ +----------+ +-----------+
192.168.1.5 121.1.2.3 10.10.29.68
```
## Testing
## Breaking changes
Test the package with the following command:
`v1.5.0`: change command timeout flag to `Duration`. See the following setting:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
username: ubuntu
password:
from_secret: ssh_password
port: 22
- command_timeout: 120
+ command_timeout: 2m
target: /home/deploy/web
source:
- release/*.tar.gz
```
$ make test
## Build or Download a binary
The pre-compiled binaries can be downloaded from [release page](https://github.com/appleboy/drone-scp/releases). Support the following OS type.
* Windows amd64/386
* Linux arm/amd64/386
* Darwin amd64/386
With `Go` installed
```sh
export GO111MODULE=on
go get -u -v github.com/appleboy/drone-scp
```
or build the binary with the following command:
```sh
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
go test -cover ./...
go build -v -a -tags netgo -o release/linux/amd64/drone-scp .
```
## Docker
Build the docker image with the following commands:
```
$ make docker
```
Please note incorrectly building the image for the correct x64 linux and with
GCO disabled will result in an error when running the Docker image:
```
docker: Error response from daemon: Container command
'/bin/drone-scp' not found or does not exist..
```sh
make docker
```
## Usage
Execute from the working directory:
There are three ways to send notification.
* [usage from binary](#usage-from-binary)
* [usage from docker](#usage-from-docker)
* [usage from drone ci](#usage-from-drone-ci)
### Usage from binary
#### Using public key
```bash
drone-scp --host example.com \
--port 22 \
--username appleboy \
--key-path "${HOME}/.ssh/id_rsa" \
--target /home/appleboy/test \
--source your_local_folder_path
```
#### Using password
```diff
drone-scp --host example.com \
--port 22 \
--username appleboy \
+ --password xxxxxxx \
--target /home/appleboy/test \
--source your_local_folder_path
```
#### Using ssh-agent
Start your local ssh agent:
```bash
eval `ssh-agent -s`
```
Import your local public key `~/.ssh/id_rsa`
```sh
ssh-add
```
You don't need to add `--password` or `--key-path` arguments.
```bash
drone-scp --host example.com \
--port 22 \
--username appleboy \
--target /home/appleboy/test \
--source your_local_folder_path
```
#### Send multiple source or target folder and hosts
```diff
drone-scp --host example1.com \
+ --host example2.com \
--port 22 \
--username appleboy \
--password xxxxxxx
--target /home/appleboy/test1 \
+ --target /home/appleboy/test2 \
--source your_local_folder_path_1
+ --source your_local_folder_path_2
```
### Usage from docker
Using public key
```bash
docker run --rm \
-e PLUGIN_HOST=http://example.com \
-e PLUGIN_USERNAME=xxxxxxx \
-e PLUGIN_PASSWORD=xxxxxxx \
-e PLUGIN_PORT=xxxxxxx \
-e PLUGIN_KEY="$(cat ${HOME}/.ssh/id_rsa)"
-e PLUGIN_SOURCE=SOURCE_FILE_LIST \
-e PLUGIN_TARGET=TARGET_FOLDER_PATH \
-e DRONE_REPO_OWNER=appleboy \
-e DRONE_REPO_NAME=go-hello \
-e DRONE_COMMIT_SHA=e5e82b5eb3737205c25955dcc3dcacc839b7be52 \
-e DRONE_COMMIT_BRANCH=master \
-e DRONE_COMMIT_AUTHOR=appleboy \
-e DRONE_BUILD_NUMBER=1 \
-e DRONE_BUILD_STATUS=success \
-e DRONE_BUILD_LINK=http://github.com/appleboy/go-hello \
-e SCP_HOST=example.com \
-e SCP_USERNAME=xxxxxxx \
-e SCP_PORT=22 \
-e SCP_KEY_PATH="${HOME}/.ssh/id_rsa"
-e SCP_SOURCE=SOURCE_FILE_LIST \
-e SCP_TARGET=TARGET_FOLDER_PATH \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-scp
```
Using password
```diff
docker run --rm \
-e SCP_HOST=example.com \
-e SCP_USERNAME=xxxxxxx \
-e SCP_PORT=22 \
+ -e SCP_PASSWORD="xxxxxxx"
-e SCP_SOURCE=SOURCE_FILE_LIST \
-e SCP_TARGET=TARGET_FOLDER_PATH \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-scp
```
Using ssh-agent, start your local ssh agent:
```bash
eval `ssh-agent -s`
```
Import your local public key `~/.ssh/id_rsa`
```sh
ssh-add
```
You don't need to add `SCP_PASSWORD` or `SCP_KEY_PATH` arguments.
```bash
docker run --rm \
-e SCP_HOST=example.com \
-e SCP_USERNAME=xxxxxxx \
-e SCP_PORT=22 \
-e SCP_SOURCE=SOURCE_FILE_LIST \
-e SCP_TARGET=TARGET_FOLDER_PATH \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-scp
```
Send multiple source or target folder and hosts
```bash
docker run --rm \
-e SCP_HOST=example1.com,example2.com \
-e SCP_USERNAME=xxxxxxx \
-e SCP_PASSWORD=xxxxxxx \
-e SCP_PORT=22 \
-e SCP_SOURCE=SOURCE_FILE_LIST_1,SOURCE_FILE_LIST_2 \
-e SCP_TARGET=TARGET_FOLDER_PATH_1,TARGET_FOLDER_PATH_2 \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-scp
```
### Usage from drone ci
Execute from the working directory:
```bash
docker run --rm \
-e PLUGIN_HOST=example.com \
-e PLUGIN_USERNAME=xxxxxxx \
-e PLUGIN_PASSWORD=xxxxxxx \
-e PLUGIN_PORT=xxxxxxx \
-e PLUGIN_SOURCE=SOURCE_FILE_LIST \
-e PLUGIN_TARGET=TARGET_FOLDER_PATH \
-e PLUGIN_RM=false \
-e PLUGIN_DEBUG=true \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-scp
```
You can get more [information](http://plugins.drone.io/appleboy/drone-scp/) about how to use scp in drone.
## Testing
Test the package with the following command:
```sh
make test
```
+12
View File
@@ -0,0 +1,12 @@
//go:build !windows
// +build !windows
package main
func rmcmd(target string) string {
return "rm -rf " + target
}
func mkdircmd(target string) string {
return "mkdir -p " + target
}
+12
View File
@@ -0,0 +1,12 @@
//go:build windows
// +build windows
package main
func rmcmd(target string) string {
return "DEL /F /S " + target
}
func mkdircmd(target string) string {
return "if not exist " + target + " mkdir " + target
}
+16
View File
@@ -0,0 +1,16 @@
FROM alpine:3.17
ARG TARGETOS
ARG TARGETARCH
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.name="Git SCP Plugin" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
RUN apk add --no-cache ca-certificates && \
rm -rf /var/cache/apk/*
COPY release/${TARGETOS}/${TARGETARCH}/drone-scp /bin/
ENTRYPOINT ["/bin/drone-scp"]
-173
View File
@@ -1,173 +0,0 @@
// Package easyssh provides a simple implementation of some SSH protocol
// features in Go. You can simply run a command on a remote server or get a file
// even simpler than native console SSH client. You don't need to think about
// Dials, sessions, defers, or public keys... Let easyssh think about it!
package easyssh
import (
"bufio"
"fmt"
"io"
"net"
"os"
"path/filepath"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
)
// Contains main authority information.
// User field should be a name of user on remote server (ex. john in ssh john@example.com).
// Server field should be a remote machine address (ex. example.com in ssh john@example.com)
// Key is a path to private key on your local machine.
// Port is SSH server port on remote machine.
// Note: easyssh looking for private key in user's home directory (ex. /home/john + Key).
// Then ensure your Key begins from '/' (ex. /.ssh/id_rsa)
type MakeConfig struct {
User string
Server string
Key string
Port string
Password string
}
// connects to remote server using MakeConfig struct and returns *ssh.Session
func (ssh_conf *MakeConfig) connect() (*ssh.Session, error) {
// auths holds the detected ssh auth methods
auths := []ssh.AuthMethod{}
// figure out what auths are requested, what is supported
if ssh_conf.Password != "" {
auths = append(auths, ssh.Password(ssh_conf.Password))
}
if sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {
auths = append(auths, ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers))
defer sshAgent.Close()
}
if ssh_conf.Key != "" {
signer, _ := ssh.ParsePrivateKey([]byte(ssh_conf.Key))
auths = append(auths, ssh.PublicKeys(signer))
}
config := &ssh.ClientConfig{
User: ssh_conf.User,
Auth: auths,
}
client, err := ssh.Dial("tcp", ssh_conf.Server+":"+ssh_conf.Port, config)
if err != nil {
return nil, err
}
session, err := client.NewSession()
if err != nil {
return nil, err
}
return session, nil
}
// Stream returns one channel that combines the stdout and stderr of the command
// as it is run on the remote machine, and another that sends true when the
// command is done. The sessions and channels will then be closed.
func (ssh_conf *MakeConfig) Stream(command string) (output chan string, done chan bool, err error) {
// connect to remote host
session, err := ssh_conf.connect()
if err != nil {
return output, done, err
}
// connect to both outputs (they are of type io.Reader)
outReader, err := session.StdoutPipe()
if err != nil {
return output, done, err
}
errReader, err := session.StderrPipe()
if err != nil {
return output, done, err
}
// combine outputs, create a line-by-line scanner
outputReader := io.MultiReader(outReader, errReader)
err = session.Start(command)
scanner := bufio.NewScanner(outputReader)
// continuously send the command's output over the channel
outputChan := make(chan string)
done = make(chan bool)
go func(scanner *bufio.Scanner, out chan string, done chan bool) {
defer close(outputChan)
defer close(done)
for scanner.Scan() {
outputChan <- scanner.Text()
}
// close all of our open resources
done <- true
session.Close()
}(scanner, outputChan, done)
return outputChan, done, err
}
// Runs command on remote machine and returns its stdout as a string
func (ssh_conf *MakeConfig) Run(command string) (outStr string, err error) {
outChan, doneChan, err := ssh_conf.Stream(command)
if err != nil {
return outStr, err
}
// read from the output channel until the done signal is passed
stillGoing := true
for stillGoing {
select {
case <-doneChan:
stillGoing = false
case line := <-outChan:
outStr += line + "\n"
}
}
// return the concatenation of all signals from the output channel
return outStr, err
}
// Scp uploads sourceFile to remote machine like native scp console app.
func (ssh_conf *MakeConfig) Scp(sourceFile string) error {
session, err := ssh_conf.connect()
if err != nil {
return err
}
defer session.Close()
targetFile := filepath.Base(sourceFile)
src, srcErr := os.Open(sourceFile)
if srcErr != nil {
return srcErr
}
srcStat, statErr := src.Stat()
if statErr != nil {
return statErr
}
go func() {
w, _ := session.StdinPipe()
fmt.Fprintln(w, "C0644", srcStat.Size(), targetFile)
if srcStat.Size() > 0 {
io.Copy(w, src)
fmt.Fprint(w, "\x00")
w.Close()
} else {
fmt.Fprint(w, "\x00")
w.Close()
}
}()
if err := session.Run(fmt.Sprintf("scp -t %s", targetFile)); err != nil {
return err
}
return nil
}
Generated
-30
View File
@@ -1,30 +0,0 @@
hash: d4830515599820a37217ef2806e6f9a3e7be66a417c46bb515fdae02b2e3b830
updated: 2016-10-19T16:23:55.991113936+08:00
imports:
- name: github.com/joho/godotenv
version: 4ed13390c0acd2ff4e371e64d8b97c8954138243
subpackages:
- autoload
- name: github.com/urfave/cli
version: 55f715e28c46073d0e217e2ce8eb46b0b45e3db6
- name: golang.org/x/crypto
version: c367d6eeb7c6158125f2f47e049f7eb7e251c09a
subpackages:
- ssh
- ssh/agent
- curve25519
- ed25519
- ed25519/internal/edwards25519
testImports:
- name: github.com/davecgh/go-spew
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
subpackages:
- spew
- name: github.com/pmezard/go-difflib
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
subpackages:
- difflib
- name: github.com/stretchr/testify
version: 976c720a22c8eb4eb6a0b4348ad85ad12491a506
subpackages:
- assert
-14
View File
@@ -1,14 +0,0 @@
package: github.com/appleboy/drone-scp
import:
- package: github.com/joho/godotenv
subpackages:
- autoload
- package: github.com/urfave/cli
- package: golang.org/x/crypto
subpackages:
- ssh
- ssh/agent
testImport:
- package: github.com/stretchr/testify
subpackages:
- assert
+27
View File
@@ -0,0 +1,27 @@
module github.com/appleboy/drone-scp
go 1.20
require (
github.com/appleboy/com v0.1.6
github.com/appleboy/easyssh-proxy v1.3.9
github.com/fatih/color v1.14.1
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.8.1
github.com/urfave/cli/v2 v2.24.4
golang.org/x/crypto v0.6.0
)
require (
github.com/ScaleFT/sshkeys v1.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.5.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+62
View File
@@ -0,0 +1,62 @@
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
github.com/ScaleFT/sshkeys v1.2.0 h1:5BRp6rTVIhJzXT3VcUQrKgXR8zWA3sOsNeuyW15WUA8=
github.com/ScaleFT/sshkeys v1.2.0/go.mod h1:gxOHeajFfvGQh/fxlC8oOKBe23xnnJTif00IFFbiT+o=
github.com/appleboy/com v0.1.6 h1:vP9ryTIbSFaXSrZcFTU7RRcgPbrpGJ0Oy5wpgEkQ2m8=
github.com/appleboy/com v0.1.6/go.mod h1:jnufjIC3opMlReyPPPye+8JqNvUzLm25o7h6SOy8nv0=
github.com/appleboy/easyssh-proxy v1.3.9 h1:b+sVSTz+cVFvfA23HQywMMpm0s5g3gH7jYdBcQqaCQI=
github.com/appleboy/easyssh-proxy v1.3.9/go.mod h1:G1eQomBEME7NWKA3hE49s5HsT44S5fn0aBxX7k9Yjug=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU=
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU=
github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+306 -92
View File
@@ -1,119 +1,307 @@
package main
import (
"log"
"os"
"time"
_ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli"
"github.com/appleboy/easyssh-proxy"
"github.com/joho/godotenv"
"github.com/urfave/cli/v2"
)
// Version for command line
var Version string
// Version set at compile-time
var (
Version string
)
func main() {
// Load env-file if it exists first
if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found {
_ = godotenv.Load(filename)
}
app := cli.NewApp()
app.Name = "telegram plugin"
app.Usage = "telegram plugin"
app.Name = "Drone SCP"
app.Usage = "Copy files and artifacts via SSH."
app.Copyright = "Copyright (c) 2020 Bo-Yi Wu"
app.Version = Version
app.Authors = []*cli.Author{
{
Name: "Bo-Yi Wu",
Email: "appleboy.tw@gmail.com",
},
}
app.Action = run
app.Version = Version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "host",
Usage: "Server host",
EnvVar: "PLUGIN_HOST,SCP_HOST",
&cli.StringSliceFlag{
Name: "host",
Aliases: []string{"H"},
Usage: "Server host",
EnvVars: []string{"PLUGIN_HOST", "SCP_HOST", "SSH_HOST", "HOST", "INPUT_HOST"},
FilePath: ".host",
},
cli.StringFlag{
Name: "port",
Value: "22",
Usage: "Server port, default to 22",
EnvVar: "PLUGIN_PORT,SCP_PORT",
&cli.StringFlag{
Name: "port",
Aliases: []string{"P"},
Value: "22",
Usage: "Server port, default to 22",
EnvVars: []string{"PLUGIN_PORT", "SCP_PORT", "SSH_PORT", "PORT", "INPUT_PORT"},
},
cli.StringFlag{
Name: "username",
Usage: "Server username",
EnvVar: "PLUGIN_USERNAME,SCP_USERNAME",
&cli.StringFlag{
Name: "username",
Aliases: []string{"u"},
Usage: "Server username",
EnvVars: []string{"PLUGIN_USERNAME", "PLUGIN_USER", "SCP_USERNAME", "SSH_USERNAME", "USERNAME", "INPUT_USERNAME"},
},
cli.StringFlag{
Name: "password",
Usage: "Password for password-based authentication",
EnvVar: "PLUGIN_PASSWORD,SCP_PASSWORD",
&cli.StringFlag{
Name: "password",
Aliases: []string{"p"},
Usage: "Password for password-based authentication",
EnvVars: []string{"PLUGIN_PASSWORD", "SCP_PASSWORD", "SSH_PASSWORD", "PASSWORD", "INPUT_PASSWORD"},
},
cli.StringFlag{
Name: "key",
Usage: "ssh private key",
EnvVar: "PLUGIN_KEY,SCP_KEY",
&cli.StringSliceFlag{
Name: "ciphers",
Usage: "The allowed cipher algorithms. If unspecified then a sensible",
EnvVars: []string{"PLUGIN_CIPHERS", "SSH_CIPHERS", "CIPHERS", "INPUT_CIPHERS"},
},
cli.StringFlag{
Name: "target",
Value: "/",
Usage: "Target path on the server, default to '/'",
EnvVar: "PLUGIN_TARGET",
&cli.BoolFlag{
Name: "useInsecureCipher",
Usage: "include more ciphers with use_insecure_cipher",
EnvVars: []string{"PLUGIN_USE_INSECURE_CIPHER", "SSH_USE_INSECURE_CIPHER", "USE_INSECURE_CIPHER", "INPUT_USE_INSECURE_CIPHER"},
},
cli.StringSliceFlag{
Name: "source",
Usage: "scp file list",
EnvVar: "PLUGIN_SOURCE",
&cli.StringFlag{
Name: "fingerprint",
Usage: "fingerprint SHA256 of the host public key, default is to skip verification",
EnvVars: []string{"PLUGIN_FINGERPRINT", "SSH_FINGERPRINT", "FINGERPRINT", "INPUT_FINGERPRINT"},
},
cli.BoolFlag{
Name: "debug",
Usage: "display message from command",
EnvVar: "PLUGIN_DEBUG",
&cli.DurationFlag{
Name: "timeout",
Usage: "connection timeout",
EnvVars: []string{"PLUGIN_TIMEOUT", "SCP_TIMEOUT", "INPUT_TIMEOUT"},
Value: 30 * time.Second,
},
cli.StringFlag{
Name: "repo.owner",
Usage: "repository owner",
EnvVar: "DRONE_REPO_OWNER",
&cli.DurationFlag{
Name: "command.timeout",
Usage: "command timeout",
EnvVars: []string{"PLUGIN_COMMAND_TIMEOUT", "SSH_COMMAND_TIMEOUT", "INPUT_COMMAND_TIMEOUT"},
Value: 10 * time.Minute,
},
cli.StringFlag{
Name: "repo.name",
Usage: "repository name",
EnvVar: "DRONE_REPO_NAME",
&cli.StringFlag{
Name: "ssh-key",
Aliases: []string{"k"},
Usage: "ssh private key",
EnvVars: []string{"PLUGIN_SSH_KEY,", "PLUGIN_KEY", "SCP_KEY", "SSH_KEY", "KEY", "INPUT_KEY"},
},
cli.StringFlag{
Name: "commit.sha",
Usage: "git commit sha",
EnvVar: "DRONE_COMMIT_SHA",
&cli.StringFlag{
Name: "ssh-passphrase",
Usage: "The purpose of the passphrase is usually to encrypt the private key.",
EnvVars: []string{"PLUGIN_SSH_PASSPHRASE", "PLUGIN_PASSPHRASE", "SSH_PASSPHRASE", "PASSPHRASE", "INPUT_PASSPHRASE"},
},
cli.StringFlag{
Name: "commit.branch",
Value: "master",
Usage: "git commit branch",
EnvVar: "DRONE_COMMIT_BRANCH",
&cli.StringFlag{
Name: "key-path",
Aliases: []string{"i"},
Usage: "ssh private key path",
EnvVars: []string{"PLUGIN_KEY_PATH", "SCP_KEY_PATH", "SSH_KEY_PATH", "INPUT_KEY_PATH"},
},
cli.StringFlag{
Name: "commit.author",
Usage: "git author name",
EnvVar: "DRONE_COMMIT_AUTHOR",
&cli.StringSliceFlag{
Name: "target",
Aliases: []string{"t"},
Usage: "Target path on the server",
EnvVars: []string{"PLUGIN_TARGET", "SCP_TARGET", "TARGET", "INPUT_TARGET"},
},
cli.StringFlag{
Name: "commit.message",
Usage: "commit message",
EnvVar: "DRONE_COMMIT_MESSAGE",
&cli.StringSliceFlag{
Name: "source",
Aliases: []string{"s"},
Usage: "scp file list",
EnvVars: []string{"PLUGIN_SOURCE", "SCP_SOURCE", "SOURCE", "INPUT_SOURCE"},
},
cli.StringFlag{
Name: "build.event",
Value: "push",
Usage: "build event",
EnvVar: "DRONE_BUILD_EVENT",
&cli.BoolFlag{
Name: "rm",
Aliases: []string{"r"},
Usage: "remove target folder before upload data",
EnvVars: []string{"PLUGIN_RM", "SCP_RM", "RM", "INPUT_RM"},
},
cli.IntFlag{
Name: "build.number",
Usage: "build number",
EnvVar: "DRONE_BUILD_NUMBER",
&cli.StringFlag{
Name: "repo.owner",
Usage: "repository owner",
EnvVars: []string{"DRONE_REPO_OWNER"},
},
cli.StringFlag{
Name: "build.status",
Usage: "build status",
Value: "success",
EnvVar: "DRONE_BUILD_STATUS",
&cli.StringFlag{
Name: "repo.name",
Usage: "repository name",
EnvVars: []string{"DRONE_REPO_NAME"},
},
cli.StringFlag{
Name: "build.link",
Usage: "build link",
EnvVar: "DRONE_BUILD_LINK",
&cli.StringFlag{
Name: "commit.sha",
Usage: "git commit sha",
EnvVars: []string{"DRONE_COMMIT_SHA"},
},
&cli.StringFlag{
Name: "commit.branch",
Value: "master",
Usage: "git commit branch",
EnvVars: []string{"DRONE_COMMIT_BRANCH"},
},
&cli.StringFlag{
Name: "commit.author",
Usage: "git author name",
EnvVars: []string{"DRONE_COMMIT_AUTHOR"},
},
&cli.StringFlag{
Name: "commit.message",
Usage: "commit message",
EnvVars: []string{"DRONE_COMMIT_MESSAGE"},
},
&cli.StringFlag{
Name: "build.event",
Value: "push",
Usage: "build event",
EnvVars: []string{"DRONE_BUILD_EVENT"},
},
&cli.IntFlag{
Name: "build.number",
Usage: "build number",
EnvVars: []string{"DRONE_BUILD_NUMBER"},
},
&cli.StringFlag{
Name: "build.status",
Usage: "build status",
Value: "success",
EnvVars: []string{"DRONE_BUILD_STATUS"},
},
&cli.StringFlag{
Name: "build.link",
Usage: "build link",
EnvVars: []string{"DRONE_BUILD_LINK"},
},
&cli.StringFlag{
Name: "proxy.ssh-key",
Usage: "private ssh key of proxy",
EnvVars: []string{"PLUGIN_PROXY_SSH_KEY", "PLUGIN_PROXY_KEY", "PROXY_SSH_KEY", "PROXY_KEY", "INPUT_PROXY_KEY"},
},
&cli.StringFlag{
Name: "proxy.ssh-passphrase",
Usage: "The purpose of the passphrase is usually to encrypt the private key.",
EnvVars: []string{"PLUGIN_PROXY_SSH_PASSPHRASE", "PLUGIN_PROXY_PASSPHRASE", "PROXY_SSH_PASSPHRASE", "PROXY_PASSPHRASE", "INPUT_PROXY_PASSPHRASE"},
},
&cli.StringFlag{
Name: "proxy.key-path",
Usage: "ssh private key path of proxy",
EnvVars: []string{"PLUGIN_PROXY_KEY_PATH", "PROXY_SSH_KEY_PATH", "INPUT_PROXY_KEY_PATH"},
},
&cli.StringFlag{
Name: "proxy.username",
Usage: "connect as user of proxy",
EnvVars: []string{"PLUGIN_PROXY_USERNAME", "PLUGIN_PROXY_USER", "PROXY_SSH_USERNAME", "PROXY_USERNAME", "INPUT_PROXY_USERNAME"},
Value: "root",
},
&cli.StringFlag{
Name: "proxy.password",
Usage: "user password of proxy",
EnvVars: []string{"PLUGIN_PROXY_PASSWORD", "PROXY_SSH_PASSWORD", "PROXY_PASSWORD", "INPUT_PROXY_PASSWORD"},
},
&cli.StringFlag{
Name: "proxy.host",
Usage: "connect to host of proxy",
EnvVars: []string{"PLUGIN_PROXY_HOST", "PROXY_SSH_HOST", "PROXY_HOST", "INPUT_PROXY_HOST"},
},
&cli.StringSliceFlag{
Name: "proxy.ciphers",
Usage: "The allowed cipher algorithms. If unspecified then a sensible",
EnvVars: []string{"PLUGIN_PROXY_CIPHERS", "PROXY_SSH_CIPHERS", "PROXY_CIPHERS", "INPUT_PROXY_CIPHERS"},
},
&cli.BoolFlag{
Name: "proxy.useInsecureCipher",
Usage: "include more ciphers with use_insecure_cipher",
EnvVars: []string{"PLUGIN_PROXY_USE_INSECURE_CIPHER", "SSH_PROXY_USE_INSECURE_CIPHER", "PROXY_USE_INSECURE_CIPHER", "INPUT_PROXY_USE_INSECURE_CIPHER"},
},
&cli.StringFlag{
Name: "proxy.fingerprint",
Usage: "fingerprint SHA256 of the host public key, default is to skip verification",
EnvVars: []string{"PLUGIN_PROXY_FINGERPRINT", "SSH_PROXY_FINGERPRINT", "PROXY_FINGERPRINT", "INPUT_PROXY_FINGERPRINT"},
},
&cli.StringFlag{
Name: "proxy.port",
Usage: "connect to port of proxy",
EnvVars: []string{"PLUGIN_PROXY_PORT", "PROXY_SSH_PORT", "PROXY_PORT", "INPUT_PROXY_PORT"},
Value: "22",
},
&cli.DurationFlag{
Name: "proxy.timeout",
Usage: "proxy connection timeout",
EnvVars: []string{"PLUGIN_PROXY_TIMEOUT", "PROXY_SSH_TIMEOUT", "INPUT_PROXY_TIMEOUT"},
},
&cli.IntFlag{
Name: "strip.components",
Usage: "Remove the specified number of leading path elements.",
EnvVars: []string{"PLUGIN_STRIP_COMPONENTS", "TAR_STRIP_COMPONENTS", "INPUT_STRIP_COMPONENTS"},
},
&cli.StringFlag{
Name: "tar.exec",
Usage: "Alternative `tar` executable to on the dest host",
EnvVars: []string{"PLUGIN_TAR_EXEC", "SCP_TAR_EXEC", "INPUT_TAR_EXEC"},
Value: "tar",
},
&cli.StringFlag{
Name: "tar.tmp-path",
Usage: "Temporary path for tar file on the dest host",
EnvVars: []string{"PLUGIN_TAR_TMP_PATH", "SCP_TAR_TMP_PATH"},
},
&cli.BoolFlag{
Name: "debug",
Usage: "remove target folder before upload data",
EnvVars: []string{"PLUGIN_DEBUG", "DEBUG", "INPUT_DEBUG"},
},
&cli.BoolFlag{
Name: "overwrite",
Usage: "use --overwrite flag with tar",
EnvVars: []string{"PLUGIN_OVERWRITE", "SCP_OVERWRITE", "INPUT_OVERWRITE"},
},
&cli.BoolFlag{
Name: "unlink.first",
Usage: "use --unlink-first flag with tar",
EnvVars: []string{"PLUGIN_UNLINK_FIRST", "SCP_UNLINK_FIRST", "INPUT_UNLINK_FIRST"},
},
}
app.Run(os.Args)
// Override a template
cli.AppHelpTemplate = `
________ ____________________________
\______ \_______ ____ ____ ____ / _____/\_ ___ \______ \
| | \_ __ \/ _ \ / \_/ __ \ ______ \_____ \ / \ \/| ___/
| | \ | \( <_> ) | \ ___/ /_____/ / \\ \___| |
/_______ /__| \____/|___| /\___ > /_______ / \______ /____|
\/ \/ \/ \/ \/
version: {{.Version}}
NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
{{if len .Authors}}
AUTHOR:
{{range .Authors}}{{ . }}{{end}}
{{end}}{{if .Commands}}
COMMANDS:
{{range .Commands}}{{if not .HideHelp}} {{join .Names ", "}}{{ "\t"}}{{.Usage}}{{ "\n" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
GLOBAL OPTIONS:
{{range .VisibleFlags}}{{.}}
{{end}}{{end}}{{if .Copyright }}
COPYRIGHT:
{{.Copyright}}
{{end}}{{if .Version}}
VERSION:
{{.Version}}
{{end}}
REPOSITORY:
Github: https://github.com/appleboy/drone-scp
`
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func run(c *cli.Context) error {
@@ -133,14 +321,40 @@ func run(c *cli.Context) error {
Link: c.String("build.link"),
},
Config: Config{
Host: c.String("host"),
Port: c.String("port"),
Username: c.String("username"),
Password: c.String("password"),
Key: c.String("key"),
Target: c.String("target"),
Source: c.StringSlice("source"),
Debug: c.Bool("debug"),
Host: c.StringSlice("host"),
Port: c.String("port"),
Username: c.String("username"),
Password: c.String("password"),
Passphrase: c.String("ssh-passphrase"),
Fingerprint: c.String("fingerprint"),
Timeout: c.Duration("timeout"),
CommandTimeout: c.Duration("command.timeout"),
Key: c.String("ssh-key"),
KeyPath: c.String("key-path"),
Target: c.StringSlice("target"),
Source: c.StringSlice("source"),
Remove: c.Bool("rm"),
Debug: c.Bool("debug"),
StripComponents: c.Int("strip.components"),
TarExec: c.String("tar.exec"),
TarTmpPath: c.String("tar.tmp-path"),
Overwrite: c.Bool("overwrite"),
UnlinkFirst: c.Bool("unlink.first"),
Ciphers: c.StringSlice("ciphers"),
UseInsecureCipher: c.Bool("useInsecureCipher"),
Proxy: easyssh.DefaultConfig{
Key: c.String("proxy.ssh-key"),
Passphrase: c.String("proxy.ssh-passphrase"),
Fingerprint: c.String("proxy.fingerprint"),
KeyPath: c.String("proxy.key-path"),
User: c.String("proxy.username"),
Password: c.String("proxy.password"),
Server: c.String("proxy.host"),
Port: c.String("proxy.port"),
Timeout: c.Duration("proxy.timeout"),
Ciphers: c.StringSlice("proxy.ciphers"),
UseInsecureCipher: c.Bool("proxy.useInsecureCipher"),
},
},
}
+8
View File
@@ -0,0 +1,8 @@
//go:build !windows
// +build !windows
package main
func getRealPath(path string) string {
return path
}
+12
View File
@@ -0,0 +1,12 @@
//go:build windows
// +build windows
package main
import (
"strings"
)
func getRealPath(path string) string {
return "/" + strings.Replace(strings.Replace(path, ":", "", -1), "\\", "/", -1)
}
+27
View File
@@ -0,0 +1,27 @@
package main
import (
"testing"
)
func TestGetRealPath(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want string
}{
{
"Test Windows Path",
"C:\\Users\\appleboy\\test.txt",
"/C/Users/appleboy/test.txt",
},
}
for _, tt := range tests {
if got := getRealPath(tt.args.path); got != tt.want {
t.Errorf("%q. getRealPath() = %v, want %v", tt.name, got, tt.want)
}
}
}
+325 -82
View File
@@ -3,14 +3,24 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
"github.com/appleboy/drone-scp/easyssh"
"github.com/appleboy/com/random"
"github.com/appleboy/easyssh-proxy"
"github.com/fatih/color"
)
var (
errMissingHost = errors.New("Error: missing server host")
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
errSetPasswordandKey = errors.New("can't set password and key at the same time")
errMissingSourceOrTarget = errors.New("missing source or target config")
)
type (
@@ -34,24 +44,48 @@ type (
// Config for the plugin.
Config struct {
Host string
Port string
Username string
Password string
Key string
Target string
Source []string
Debug bool
Host []string
Port string
Username string
Password string
Key string
Passphrase string
Fingerprint string
KeyPath string
Timeout time.Duration
CommandTimeout time.Duration
Target []string
Source []string
Remove bool
StripComponents int
TarExec string
TarTmpPath string
Proxy easyssh.DefaultConfig
Debug bool
Overwrite bool
UnlinkFirst bool
Ciphers []string
UseInsecureCipher bool
}
// Plugin values.
Plugin struct {
Repo Repo
Build Build
Config Config
Repo Repo
Build Build
Config Config
DestFile string
}
copyError struct {
host string
message string
}
)
func (e copyError) Error() string {
return fmt.Sprintf("error copy file to dest: %s, error message: %s\n", e.host, e.message)
}
func trimPath(keys []string) []string {
var newKeys []string
@@ -67,98 +101,307 @@ func trimPath(keys []string) []string {
return newKeys
}
// Exec executes the plugin.
func (p Plugin) Exec() error {
func globList(paths []string) fileList {
var list fileList
if len(p.Config.Host) == 0 || len(p.Config.Username) == 0 || (len(p.Config.Password) == 0 && len(p.Config.Key) == 0) {
log.Println("missing ssh config (Host, Username, Password or Key)")
for _, pattern := range paths {
ignore := false
pattern = strings.Trim(pattern, " ")
if string(pattern[0]) == "!" {
pattern = pattern[1:]
ignore = true
}
matches, err := filepath.Glob(pattern)
if err != nil {
fmt.Printf("Glob error for %q: %s\n", pattern, err)
continue
}
return errors.New("missing ssh config (Host, Username, Password or Key)")
if ignore {
list.Ignore = append(list.Ignore, matches...)
} else {
list.Source = append(list.Source, matches...)
}
}
if len(p.Config.Source) == 0 {
log.Println("missing source file list config")
return list
}
return errors.New("missing source file list config")
func buildArgs(tar string, files fileList) []string {
args := []string{}
if len(files.Ignore) > 0 {
for _, v := range files.Ignore {
args = append(args, "--exclude")
args = append(args, v)
}
}
args = append(args, "-cf")
args = append(args, getRealPath(tar))
args = append(args, files.Source...)
files := trimPath(p.Config.Source)
src := strings.Join(files, " ")
dest := fmt.Sprintf("%s-%s.tar", p.Repo.Name, p.Build.Commit[:7])
return args
}
// create a temporary file for the archive
dir, err := ioutil.TempDir("", "")
func (p Plugin) log(host string, message ...interface{}) {
if count := len(p.Config.Host); count == 1 {
fmt.Printf("%s", fmt.Sprintln(message...))
} else {
fmt.Printf("%s: %s", host, fmt.Sprintln(message...))
}
}
func (p *Plugin) removeDestFile(ssh *easyssh.MakeConfig) error {
p.log(ssh.Server, "remove file", p.DestFile)
_, errStr, _, err := ssh.Run(rmcmd(p.DestFile), p.Config.CommandTimeout)
if err != nil {
return err
}
tar := filepath.Join(dir, dest)
if errStr != "" {
return errors.New(errStr)
}
return nil
}
func (p *Plugin) removeAllDestFile() error {
for _, host := range p.Config.Host {
ssh := &easyssh.MakeConfig{
Server: host,
User: p.Config.Username,
Password: p.Config.Password,
Port: p.Config.Port,
Key: p.Config.Key,
KeyPath: p.Config.KeyPath,
Passphrase: p.Config.Passphrase,
Timeout: p.Config.Timeout,
Ciphers: p.Config.Ciphers,
Fingerprint: p.Config.Fingerprint,
UseInsecureCipher: p.Config.UseInsecureCipher,
Proxy: easyssh.DefaultConfig{
Server: p.Config.Proxy.Server,
User: p.Config.Proxy.User,
Password: p.Config.Proxy.Password,
Port: p.Config.Proxy.Port,
Key: p.Config.Proxy.Key,
KeyPath: p.Config.Proxy.KeyPath,
Passphrase: p.Config.Proxy.Passphrase,
Timeout: p.Config.Proxy.Timeout,
Ciphers: p.Config.Proxy.Ciphers,
Fingerprint: p.Config.Proxy.Fingerprint,
UseInsecureCipher: p.Config.Proxy.UseInsecureCipher,
},
}
// remove tar file
err := p.removeDestFile(ssh)
if err != nil {
return err
}
}
return nil
}
type fileList struct {
Ignore []string
Source []string
}
func (p *Plugin) buildArgs(target string) []string {
args := []string{}
args = append(args,
p.Config.TarExec,
"-xf",
p.DestFile,
)
if p.Config.StripComponents > 0 {
args = append(args, "--strip-components")
args = append(args, strconv.Itoa(p.Config.StripComponents))
}
if p.Config.Overwrite {
args = append(args, "--overwrite")
}
if p.Config.UnlinkFirst {
args = append(args, "--unlink-first")
}
args = append(args,
"-C",
target,
)
return args
}
// Exec executes the plugin.
func (p *Plugin) Exec() error {
if len(p.Config.Host) == 0 {
return errMissingHost
}
if len(p.Config.Key) == 0 && len(p.Config.Password) == 0 && len(p.Config.KeyPath) == 0 {
return errMissingPasswordOrKey
}
if len(p.Config.Key) != 0 && len(p.Config.Password) != 0 {
return errSetPasswordandKey
}
if len(p.Config.Source) == 0 || len(p.Config.Target) == 0 {
return errMissingSourceOrTarget
}
files := globList(trimPath(p.Config.Source))
p.DestFile = fmt.Sprintf("%s.tar", random.String(10))
// create a temporary file for the archive
dir := os.TempDir()
tar := filepath.Join(dir, p.DestFile)
// run archive command
log.Println("tar all files into " + tar)
cmd := exec.Command("tar", "-cf", tar, src)
fmt.Println("tar all files into " + tar)
args := buildArgs(tar, files)
cmd := exec.Command(p.Config.TarExec, args...)
if p.Config.Debug {
fmt.Println("$", strings.Join(cmd.Args, " "))
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return err
}
// Create MakeConfig instance with remote username, server address and path to private key.
ssh := &easyssh.MakeConfig{
Server: p.Config.Host,
User: p.Config.Username,
Password: p.Config.Password,
Port: p.Config.Port,
Key: p.Config.Key,
wg := sync.WaitGroup{}
wg.Add(len(p.Config.Host))
errChannel := make(chan error)
finished := make(chan struct{})
for _, host := range p.Config.Host {
go func(host string) {
// Create MakeConfig instance with remote username, server address and path to private key.
ssh := &easyssh.MakeConfig{
Server: host,
User: p.Config.Username,
Password: p.Config.Password,
Port: p.Config.Port,
Key: p.Config.Key,
KeyPath: p.Config.KeyPath,
Passphrase: p.Config.Passphrase,
Timeout: p.Config.Timeout,
Ciphers: p.Config.Ciphers,
Fingerprint: p.Config.Fingerprint,
UseInsecureCipher: p.Config.UseInsecureCipher,
Proxy: easyssh.DefaultConfig{
Server: p.Config.Proxy.Server,
User: p.Config.Proxy.User,
Password: p.Config.Proxy.Password,
Port: p.Config.Proxy.Port,
Key: p.Config.Proxy.Key,
KeyPath: p.Config.Proxy.KeyPath,
Passphrase: p.Config.Proxy.Passphrase,
Timeout: p.Config.Proxy.Timeout,
Ciphers: p.Config.Proxy.Ciphers,
Fingerprint: p.Config.Proxy.Fingerprint,
UseInsecureCipher: p.Config.Proxy.UseInsecureCipher,
},
}
// upload file to the tmp path
p.DestFile = fmt.Sprintf("%s%s", p.Config.TarTmpPath, p.DestFile)
// Call Scp method with file you want to upload to remote server.
p.log(host, "scp file to server.")
err := ssh.Scp(tar, p.DestFile)
if err != nil {
errChannel <- copyError{host, err.Error()}
return
}
for _, target := range p.Config.Target {
// remove target folder before upload data
if p.Config.Remove {
p.log(host, "Remove target folder:", target)
_, _, _, err := ssh.Run(rmcmd(target), p.Config.CommandTimeout)
if err != nil {
errChannel <- err
return
}
}
p.log(host, "create folder", target)
_, errStr, _, err := ssh.Run(mkdircmd(target), p.Config.CommandTimeout)
if err != nil {
errChannel <- err
return
}
if len(errStr) != 0 {
errChannel <- fmt.Errorf(errStr)
return
}
// untar file
p.log(host, "untar file", p.DestFile)
commamd := strings.Join(p.buildArgs(target), " ")
if p.Config.Debug {
fmt.Println("$", commamd)
}
outStr, errStr, _, err := ssh.Run(commamd, p.Config.CommandTimeout)
if outStr != "" {
p.log(host, "output: ", outStr)
}
if errStr != "" {
p.log(host, "error: ", errStr)
}
if err != nil {
errChannel <- err
return
}
}
// remove tar file
err = p.removeDestFile(ssh)
if err != nil {
errChannel <- err
return
}
wg.Done()
}(host)
}
// Call Scp method with file you want to upload to remote server.
log.Println("scp file to remote server remote server.")
err = ssh.Scp(tar)
go func() {
wg.Wait()
close(finished)
}()
// Handle errors
if err != nil {
log.Println(err.Error())
return err
select {
case <-finished:
case err := <-errChannel:
if err != nil {
c := color.New(color.FgRed)
c.Println("drone-scp error: ", err)
if _, ok := err.(copyError); !ok {
fmt.Println("drone-scp rollback: remove all target tmp file")
if err := p.removeAllDestFile(); err != nil {
return err
}
}
return err
}
}
// mkdir path
log.Println("create remote folder " + p.Config.Target)
response, err := ssh.Run(fmt.Sprintf("mkdir -p %s", p.Config.Target))
if p.Config.Debug {
log.Println(response)
}
if err != nil {
log.Println(err.Error())
return err
}
// untar file
log.Println("untar remote file " + dest)
response, err = ssh.Run(fmt.Sprintf("tar -xf %s -C %s", dest, p.Config.Target))
if p.Config.Debug {
log.Println(response)
}
if err != nil {
log.Println(err.Error())
return err
}
// remove tar file
log.Println("remove remote file " + dest)
response, err = ssh.Run(fmt.Sprintf("rm -rf %s", dest))
if p.Config.Debug {
log.Println(response)
}
if err != nil {
log.Println(err.Error())
return err
}
fmt.Println("===================================================")
fmt.Println("✅ Successfully executed transfer data to all host")
fmt.Println("===================================================")
return nil
}
+662 -5
View File
@@ -1,12 +1,21 @@
package main
import (
"github.com/stretchr/testify/assert"
"log"
"os"
"os/exec"
"os/user"
"path/filepath"
"reflect"
"testing"
"time"
"github.com/appleboy/easyssh-proxy"
"github.com/stretchr/testify/assert"
"golang.org/x/crypto/ssh"
)
func TestMissingConfig(t *testing.T) {
func TestMissingAllConfig(t *testing.T) {
var plugin Plugin
err := plugin.Exec()
@@ -17,7 +26,7 @@ func TestMissingConfig(t *testing.T) {
func TestMissingSSHConfig(t *testing.T) {
plugin := Plugin{
Config: Config{
Host: "example.com",
Host: []string{"example.com"},
Username: "ubuntu",
},
}
@@ -30,7 +39,7 @@ func TestMissingSSHConfig(t *testing.T) {
func TestMissingSourceConfig(t *testing.T) {
plugin := Plugin{
Config: Config{
Host: "example.com",
Host: []string{"example.com"},
Username: "ubuntu",
Port: "443",
Password: "1234",
@@ -42,6 +51,23 @@ func TestMissingSourceConfig(t *testing.T) {
assert.NotNil(t, err)
}
func TestSetPasswordAndKey(t *testing.T) {
plugin := Plugin{
Config: Config{
Host: []string{"example.com"},
Username: "ubuntu",
Port: "443",
Password: "1234",
Key: "test",
},
}
err := plugin.Exec()
assert.NotNil(t, err)
assert.Equal(t, errSetPasswordandKey, err)
}
func TestTrimElement(t *testing.T) {
var input, result []string
@@ -55,3 +81,634 @@ func TestTrimElement(t *testing.T) {
assert.Equal(t, result, trimPath(input))
}
func TestSCPFileFromPublicKey(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{filepath.Join(u.HomeDir, "/test")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test/tests/a.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test/tests/b.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
// Test -rm flag
plugin.Config.Source = []string{"tests/a.txt"}
plugin.Config.Remove = true
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test/tests/b.txt")); os.IsExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestSCPFileFromPublicKeyWithPassphrase(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/test",
Passphrase: "1234",
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{filepath.Join(u.HomeDir, "/test2")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test2/tests/a.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test2/tests/b.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestWrongFingerprint(t *testing.T) {
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "./tests/.ssh/id_rsa",
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{filepath.Join(u.HomeDir, "/test2")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
Fingerprint: "wrong",
},
}
err = plugin.Exec()
log.Println(err)
assert.NotNil(t, err)
}
func getHostPublicKeyFile(keypath string) (ssh.PublicKey, error) {
var pubkey ssh.PublicKey
var err error
buf, err := os.ReadFile(keypath)
if err != nil {
return nil, err
}
pubkey, _, _, _, err = ssh.ParseAuthorizedKey(buf)
if err != nil {
return nil, err
}
return pubkey, nil
}
func TestSCPFileFromPublicKeyWithFingerprint(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
hostKey, err := getHostPublicKeyFile("/etc/ssh/ssh_host_rsa_key.pub")
assert.NoError(t, err)
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "./tests/.ssh/id_rsa",
Fingerprint: ssh.FingerprintSHA256(hostKey),
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{filepath.Join(u.HomeDir, "/test2")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test2/tests/a.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test2/tests/b.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestSCPWildcardFileList(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*"},
Target: []string{filepath.Join(u.HomeDir, "abc")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "abc/tests/global/c.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "abc/tests/global/d.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestSCPFromProxySetting(t *testing.T) {
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*"},
Target: []string{filepath.Join(u.HomeDir, "def")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
Proxy: easyssh.DefaultConfig{
Server: "localhost",
User: "drone-scp",
Port: "22",
KeyPath: "./tests/.ssh/id_rsa",
},
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "def/tests/global/c.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "def/tests/global/d.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestStripComponentsFlag(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*"},
StripComponents: 2,
Target: []string{filepath.Join(u.HomeDir, "123")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "123/c.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "123/d.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestUseInsecureCipherFlag(t *testing.T) {
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*"},
StripComponents: 2,
Target: []string{filepath.Join(u.HomeDir, "123")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
UseInsecureCipher: true,
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "123/c.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "123/d.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestIgnoreList(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*", "!tests/global/c.txt", "!tests/global/e.txt"},
StripComponents: 2,
Target: []string{filepath.Join(u.HomeDir, "ignore")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
Debug: true,
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/c.txt")); err == nil {
t.Fatal("c.txt file exist")
}
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/e.txt")); err == nil {
t.Fatal("c.txt file exist")
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "ignore/d.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
// func TestSCPFileFromSSHAgent(t *testing.T) {
// if os.Getenv("SSH_AUTH_SOCK") == "" {
// exec.Command("eval", "`ssh-agent -s`").Run()
// exec.Command("ssh-add", "tests/.ssh/id_rsa").Run()
// }
// u, err := user.Lookup("drone-scp")
// if err != nil {
// t.Fatalf("Lookup: %v", err)
// }
// plugin := Plugin{
// Config: Config{
// Host: []string{"localhost"},
// Username: "drone-scp",
// Port: "22",
// Source: []string{"tests/a.txt", "tests/b.txt"},
// Target: []string{u.HomeDir + "/test"},
// },
// }
// err = plugin.Exec()
// assert.Nil(t, err)
// }
// func TestSCPFileFromPassword(t *testing.T) {
// u, err := user.Lookup("drone-scp")
// if err != nil {
// t.Fatalf("Lookup: %v", err)
// }
// plugin := Plugin{
// Config: Config{
// Host: []string{"localhost"},
// Username: "drone-scp",
// Port: "22",
// Password: "1234",
// Source: []string{"tests/a.txt", "tests/b.txt"},
// Target: []string{u.HomeDir + "/test"},
// },
// }
// err = plugin.Exec()
// assert.Nil(t, err)
// }
func TestIncorrectPassword(t *testing.T) {
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
Password: "123456",
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{"/home"},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err := plugin.Exec()
assert.NotNil(t, err)
}
func TestNoPermissionCreateFolder(t *testing.T) {
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{"/etc/test"},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.NotNil(t, err)
// check tmp file exist
if _, err = os.Stat(filepath.Join(u.HomeDir, plugin.DestFile)); os.IsExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestGlobList(t *testing.T) {
// wrong patern
paterns := []string{"[]a]", "tests/?.txt"}
expects := []string{"tests/a.txt", "tests/b.txt"}
assert.Equal(t, expects, globList(paterns).Source)
paterns = []string{"tests/*.txt", "tests/.ssh/*", "abc*"}
expects = []string{"tests/a.txt", "tests/b.txt", "tests/.ssh/id_rsa", "tests/.ssh/id_rsa.pub", "tests/.ssh/test", "tests/.ssh/test.pub"}
assert.Equal(t, expects, globList(paterns).Source)
paterns = []string{"tests/?.txt"}
expects = []string{"tests/a.txt", "tests/b.txt"}
assert.Equal(t, expects, globList(paterns).Source)
// remove item which file not found.
paterns = []string{"tests/aa.txt", "tests/b.txt"}
expects = []string{"tests/b.txt"}
assert.Equal(t, expects, globList(paterns).Source)
paterns = []string{"./tests/b.txt"}
expects = []string{"./tests/b.txt"}
assert.Equal(t, expects, globList(paterns).Source)
paterns = []string{"./tests/*.txt", "!./tests/b.txt"}
expectSources := []string{"tests/a.txt", "tests/b.txt"}
expectIgnores := []string{"./tests/b.txt"}
result := globList(paterns)
assert.Equal(t, expectSources, result.Source)
assert.Equal(t, expectIgnores, result.Ignore)
}
func TestBuildArgs(t *testing.T) {
list := fileList{
Source: []string{"tests/a.txt", "tests/b.txt", "tests/c.txt"},
Ignore: []string{"tests/a.txt", "tests/b.txt"},
}
result := buildArgs("test.tar.gz", list)
expects := []string{"--exclude", "tests/a.txt", "--exclude", "tests/b.txt", "-cf", "test.tar.gz", "tests/a.txt", "tests/b.txt", "tests/c.txt"}
assert.Equal(t, expects, result)
list = fileList{
Source: []string{"tests/a.txt", "tests/b.txt"},
}
result = buildArgs("test.tar.gz", list)
expects = []string{"-cf", "test.tar.gz", "tests/a.txt", "tests/b.txt"}
assert.Equal(t, expects, result)
}
func TestRemoveDestFile(t *testing.T) {
ssh := &easyssh.MakeConfig{
Server: "localhost",
User: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
// io timeout
Timeout: 1,
}
plugin := Plugin{
Config: Config{
CommandTimeout: 60 * time.Second,
},
DestFile: "/etc/resolv.conf",
}
// ssh io timeout
err := plugin.removeDestFile(ssh)
assert.Error(t, err)
ssh.Timeout = 0
// permission denied
err = plugin.removeDestFile(ssh)
assert.Error(t, err)
}
func TestPlugin_buildArgs(t *testing.T) {
type fields struct {
Repo Repo
Build Build
Config Config
DestFile string
}
type args struct {
target string
}
tests := []struct {
name string
fields fields
args args
want []string
}{
{
name: "default command",
fields: fields{
Config: Config{
Overwrite: false,
UnlinkFirst: false,
TarExec: "tar",
},
DestFile: "foo.tar",
},
args: args{
target: "foo",
},
want: []string{"tar", "-xf", "foo.tar", "-C", "foo"},
},
{
name: "strip components",
fields: fields{
Config: Config{
Overwrite: false,
UnlinkFirst: false,
TarExec: "tar",
StripComponents: 2,
},
DestFile: "foo.tar",
},
args: args{
target: "foo",
},
want: []string{"tar", "-xf", "foo.tar", "--strip-components", "2", "-C", "foo"},
},
{
name: "overwrite",
fields: fields{
Config: Config{
TarExec: "tar",
StripComponents: 2,
Overwrite: true,
UnlinkFirst: false,
},
DestFile: "foo.tar",
},
args: args{
target: "foo",
},
want: []string{"tar", "-xf", "foo.tar", "--strip-components", "2", "--overwrite", "-C", "foo"},
},
{
name: "unlink first",
fields: fields{
Config: Config{
TarExec: "tar",
StripComponents: 2,
Overwrite: true,
UnlinkFirst: true,
},
DestFile: "foo.tar",
},
args: args{
target: "foo",
},
want: []string{"tar", "-xf", "foo.tar", "--strip-components", "2", "--overwrite", "--unlink-first", "-C", "foo"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := &Plugin{
Repo: tt.fields.Repo,
Build: tt.fields.Build,
Config: tt.fields.Config,
DestFile: tt.fields.DestFile,
}
if got := p.buildArgs(tt.args.target); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Plugin.buildArgs() = %v, want %v", got, tt.want)
}
})
}
}
+27
View File
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA4e2D/qPN08pzTac+a8ZmlP1ziJOXk45CynMPtva0rtK/RB26
VbfAF0hIJji7ltvnYnqCU9oFfvEM33cTn7T96+od8ib/Vz25YU8ZbstqtIskPuwC
bv3K0mAHgsviJyRD7yM+QKTbBQEgbGuW6gtbMKhiYfiIB4Dyj7AdS/fk3v26wDgz
7SHI5OBqu9bv1KhxQYdFEnU3PAtAqeccgzNpbH3eYLyGzuUxEIJlhpZ/uU2G9ppj
/cSrONVPiI8Ahi4RrlZjmP5l57/sq1ClGulyLpFcMw68kP5FikyqHpHJHRBNgU57
1y0Ph33SjBbs0haCIAcmreWEhGe+/OXnJe6VUQIDAQABAoIBAH97emORIm9DaVSD
7mD6DqA7c5m5Tmpgd6eszU08YC/Vkz9oVuBPUwDQNIX8tT0m0KVs42VVPIyoj874
bgZMJoucC1G8V5Bur9AMxhkShx9g9A7dNXJTmsKilRpk2TOk7wBdLp9jZoKoZBdJ
jlp6FfaazQjjKD6zsCsMATwAoRCBpBNsmT6QDN0n0bIgY0tE6YGQaDdka0dAv68G
R0VZrcJ9voT6+f+rgJLoojn2DAu6iXaM99Gv8FK91YCymbQlXXgrk6CyS0IHexN7
V7a3k767KnRbrkqd3o6JyNun/CrUjQwHs1IQH34tvkWScbseRaFehcAm6mLT93RP
muauvMECgYEA9AXGtfDMse0FhvDPZx4mx8x+vcfsLvDHcDLkf/lbyPpu97C27b/z
ia07bu5TAXesUZrWZtKA5KeRE5doQSdTOv1N28BEr8ZwzDJwfn0DPUYUOxsN2iIy
MheO5A45Ko7bjKJVkZ61Mb1UxtqCTF9mqu9R3PBdJGthWOd+HUvF460CgYEA7QRf
Z8+vpGA+eSuu29e0xgRKnRzed5zXYpcI4aERc3JzBgO4Z0er9G8l66OWVGdMfpe6
CBajC5ToIiT8zqoYxXwqJgN+glir4gJe3mm8J703QfArZiQrdk0NTi5bY7+vLLG/
knTrtpdsKih6r3kjhuPPaAsIwmMxIydFvATKjLUCgYEAh/y4EihRSk5WKC8GxeZt
oiZ58vT4z+fqnMIfyJmD5up48JuQNcokw/LADj/ODiFM7GUnWkGxBrvDA3H67WQm
49bJjs8E+BfUQFdTjYnJRlpJZ+7Zt1gbNQMf5ENw5CCchTDqEq6pN0DVf8PBnSIF
KvkXW9KvdV5J76uCAn15mDkCgYA1y8dHzbjlCz9Cy2pt1aDfTPwOew33gi7U3skS
RTerx29aDyAcuQTLfyrROBkX4TZYiWGdEl5Bc7PYhCKpWawzrsH2TNa7CRtCOh2E
R+V/84+GNNf04ALJYCXD9/ugQVKmR1XfDRCvKeFQFE38Y/dvV2etCswbKt5tRy2p
xkCe/QKBgQCkLqafD4S20YHf6WTp3jp/4H/qEy2X2a8gdVVBi1uKkGDXr0n+AoVU
ib4KbP5ovZlrjL++akMQ7V2fHzuQIFWnCkDA5c2ZAqzlM+ZN+HRG7gWur7Bt4XH1
7XC9wlRna4b3Ln8ew3q1ZcBjXwD4ppbTlmwAfQIaZTGJUgQbdsO9YA==
-----END RSA PRIVATE KEY-----
+1
View File
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDh7YP+o83TynNNpz5rxmaU/XOIk5eTjkLKcw+29rSu0r9EHbpVt8AXSEgmOLuW2+dieoJT2gV+8QzfdxOftP3r6h3yJv9XPblhTxluy2q0iyQ+7AJu/crSYAeCy+InJEPvIz5ApNsFASBsa5bqC1swqGJh+IgHgPKPsB1L9+Te/brAODPtIcjk4Gq71u/UqHFBh0USdTc8C0Cp5xyDM2lsfd5gvIbO5TEQgmWGln+5TYb2mmP9xKs41U+IjwCGLhGuVmOY/mXnv+yrUKUa6XIukVwzDryQ/kWKTKoekckdEE2BTnvXLQ+HfdKMFuzSFoIgByat5YSEZ7785ecl7pVR drone-scp@localhost
+50
View File
@@ -0,0 +1,50 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABAZka7A7i
FscMeJBPyPteclAAAAEAAAAAEAAAIXAAAAB3NzaC1yc2EAAAADAQABAAACAQDz6aZ1jY2o
nnuj2YNHJ/HhfvIu0B973v/+pFFOavnTUOhEEKEy3TASu+s9CkHrYZAtRc+QYIkNZI31mh
HBhotdeP/7GoO2UirkFtrzyQKPNJxEcv0RBoG9ssN8jex0PyK6DHIYYFnIWadVBEEOh/H+
rK7j7u2/big3oTzYBuFrCwmYFcz5na99MzFeAUhazF44gVBma+zO+1quGeqF51UDIg1SMG
vX8I7LNEqrKEBaIUQJKFQcxlOWlRLQsjJCymrOujsXsRrXHAQWcnxDcNevv2ZMOUl0ybvv
9yH0BiGbRBd1Hy8/QPILbAQaqu0oQE7fubN8Q8lqb3Jg0loID4x/5GPhSY8WAXpuLcXTOr
b93SnCw1JsAgJDNqpuuRFy3BSZ7wBOr1jfeIoo7xk14OHiUjJ0uXDL9cLMkcw6ElWz81mr
D2VCkXUz+qFyjJ+G7aGWRtctZoOzKln4yfNfUmwW8/8ra3QnmrMZ2xW2Ylw3ZhO+tLi7jI
NHYFb54bAdLVPUU1ctIuJns2qkWnjJCxxMiynIqCif20/OU1n8CTJuOWiURmRdmvKOH4PE
3JxC2Qnk/3tV3Cf8hp1CH5VjBZ9AjGj5MDMHXyu34VY2WvYo5QyzfS3ySPoT8kCO0G0xpv
jwCMHOK+G2RP4kqb/KKZguiKdgintBXuskTlJmD7kcMQAAB1CnEMQGwAKZbd3F1DJqwfPf
KWjoUJKbTRiav6h5pQr65JaqDe/7YE2ZHYo5917AC2vPLwPxAnoHFMsbObd5mWcmpATg/0
K/qkN5Z4Ml5U3bwr51wfSPh1MiAP21Aickt09BDstIJzNNwwgcY31O3k/d6VBjqyM6Ezop
66LI4s/IIni1BI+cALyEfzE4Qu16GfzIeM+JVxildP4VImhvNBESmmbBL8rNmSzlQ+FTuF
JVmowUbcon1O0CppM1MRVPeG805XDwjxHXKwOp5O7MdTz7H8JeORoe8D6+4rNfJE0eQGY7
Nm4+Wa97HzAFbT9IS433rxoGx9Qps3LAySFONso2JWSOEfo8rxnqO04DrfVHQhY3DkkwQt
FsDnMtkthJa+ZzUYc75fnS0DBPGuF9DZUCqrev5oAUHP6C4Vc4b33JJQD4FZJ+ehk3Xsci
cwJQsmgLyc5Jdh543Dm7kZoM9ku7HDNrB4H/1p45Vo6aBZMAY50x+fTdBeTgCzzhzzTbf+
0IF8W3yW3/BYD+S2Byo3JKp6NH0Q8cgPJrGTl6GltGfpVuc6kLjMZ5zvxRbyWaqtIygM46
W1izbA+9jwbHhitCtOk42e/ff6iEB1MVC13LqPty3gPNR8Pv0rDUDjJS4KiVwXqUY+bMr0
C8l/hx93euHjLUJ49Ru6uy/2fBlHZEj6GmEAJhu/i6t2c1Rq0HBLis9X356oQT+YZnIai2
ym0MknPxjeYBAItOV3zhRd1cYnk7CDcl1XALcnh0tqP712x24IJ+Ytqg7nvB2NZV8T469I
8Fp254Nr89HOMAXaZD0UcIPm7D2rfWV+YJFI3ZcJ/8DM99H3tpXe2j4oHMdmAbBd++09sx
KBRdFLcvnBfd1lqwxpA7hbxzrxi/yehYCqzh5KQGaf2UXej6TPiVzBWVYbp34cMZtsT6mF
K8SS3l5TXoNK2DNEk30o8K3q+vngQpfC9GZ/id4B7LS/3ybellxemZHXQoU4PxDkLKt7jd
AAsd5WO13dv3n/qgyu8iBRiFU+W66NX0RJGkp+lZMnta0YzukafM2n6GDn/r/Cx/y21PAi
ah8i41ByI1QLI4m1r+bRHdUxAarS/XJw4tTSFiZu3zddMYrlzeG9O3VUX9zBvBtfQbSmeJ
omml0zlr/qD7TMsORiujy7XIn7sMW+Ls/NA8TvX8oRnACjXe/MYNEZ8WDu2rkZuY/Dfc+o
NyYWO7kZ3kcejQZ1NusJSA7MG0FFGYSIaC9T9CWqYd5IcRSJW4dZnCt9z8CIJ6TSUFqMb/
H1Y5Rmi0IIX+8qbGGXVBDIBk5y9xtS43+nz1nsdXwDmkTiXN9+ZX+GDsLxCWoHGryrWDbk
EuOAlqpvxFKzEkNsx+AC5wae6i/hBeiEce9bm4nZp+hFv1ic1Z9WS8B37YOFgJ4utGeOjB
6hnywUUJ3aH0LnCQNB3UzeFR7BmEaxmYD/phJodmjA5SD3CWpeizdXfrUjtqXGhYlr2jzq
vBAeeYEO4uaHIGxg8GqoqtaseqVcIdtouHxrVAxxXkjShV2ji7oJ/AtrLZNlkKYxMk0TpX
fFiKqL/uKfS78FfvVOhOkHZTD6ZeMgmdL/uOghEAtrf08ChyRvdp7QLjA802aio9eUVIQm
lHb1ltPEbIZNuvQ5kTIwk2eM6EAkOh0MBMoAYOxOpIb00XHNRDGJYuLewByjMQa8EoT6VM
NoiFIzJU9lLAXE6yz6JswctpTpLHK9Aq5vY7ObaOvrmpCQqsXfOuVUo2nR/FyEes97zuXG
E4aKaHK4IAW4UY/oGYk7pU/yRpudhiNRMXzmcQXfVmBEHuvDrh2chg8lDYn++07F7RWqkI
nfMAOWR8UEl4xp4zJtThDjRxNW6QLl8E1ADjndA9wVaKNSzv2i1TLXKBr5luFqY9MSJ2rm
yBR5EwairH/Qn9TUxaDD+0p6J+E9iz1l8UPTJa/cjtwiySljahY/6tHHnr9YQVnox92yfU
UXpfINGjYrpqh6EFwmyRw9fryIMvMhgZYo6ZoCRBCK2GfGAB0VTzJy2FGs4GecZK5ptXKu
sOX8BgGX/Q/nAJ7PWf9hgYlX2YyjmLjQZDMWECp05VFx9znEETNKlwF1FX5/E/37ISyz4d
I1LVSKOEccJX7jCR32LzvRW1UBX47Z+q3LVE4sa0QAV/JoISq6Qn6zAsVIV0yEPmVbd/xx
aX2uBUGHhmd99YJDh81xJIoYEMRzoGVfp0JjfYcDUc+2I6JdrOMF9/KmMA5wsZl4OKiu/F
cTRGjUkgw/cF2EFRGWknee2esYRB7tOr4y56qZ4gxqw8q9rYXhyB42jbdTvt5xcCm/ynid
sn4InokRRoIiMIPL5Ur7FZQHOP+915MWUBsrTJtkCWQuqJheYUi3mCzh/7NadAKplRpaKb
rS/DJIOOkjnGni/sDxJzPq7STDBVy4WStwQl6NI5hq+/c+JvN9GI4Vu/kz0z8qUcdShLaH
l4njcaMpg4tpQMHtCBOicGyV0=
-----END OPENSSH PRIVATE KEY-----
+1
View File
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDz6aZ1jY2onnuj2YNHJ/HhfvIu0B973v/+pFFOavnTUOhEEKEy3TASu+s9CkHrYZAtRc+QYIkNZI31mhHBhotdeP/7GoO2UirkFtrzyQKPNJxEcv0RBoG9ssN8jex0PyK6DHIYYFnIWadVBEEOh/H+rK7j7u2/big3oTzYBuFrCwmYFcz5na99MzFeAUhazF44gVBma+zO+1quGeqF51UDIg1SMGvX8I7LNEqrKEBaIUQJKFQcxlOWlRLQsjJCymrOujsXsRrXHAQWcnxDcNevv2ZMOUl0ybvv9yH0BiGbRBd1Hy8/QPILbAQaqu0oQE7fubN8Q8lqb3Jg0loID4x/5GPhSY8WAXpuLcXTOrb93SnCw1JsAgJDNqpuuRFy3BSZ7wBOr1jfeIoo7xk14OHiUjJ0uXDL9cLMkcw6ElWz81mrD2VCkXUz+qFyjJ+G7aGWRtctZoOzKln4yfNfUmwW8/8ra3QnmrMZ2xW2Ylw3ZhO+tLi7jINHYFb54bAdLVPUU1ctIuJns2qkWnjJCxxMiynIqCif20/OU1n8CTJuOWiURmRdmvKOH4PE3JxC2Qnk/3tV3Cf8hp1CH5VjBZ9AjGj5MDMHXyu34VY2WvYo5QyzfS3ySPoT8kCO0G0xpvjwCMHOK+G2RP4kqb/KKZguiKdgintBXuskTlJmD7kcMQ== deploy@easyssh
+1
View File
@@ -0,0 +1 @@
appleboy
View File
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then
# generate fresh rsa key
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
fi
if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then
# generate fresh dsa key
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
fi
exec "$@"
View File
View File
View File