forked from babashka/pod-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bbssh.clj
38 lines (30 loc) · 1.07 KB
/
bbssh.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bb
(require '[babashka.pods :as pods]
'[clojure.java.io :as io])
(pods/load-pod 'epiccastle/bbssh "0.3.0")
(require '[pod.epiccastle.bbssh.core :as bbssh]
'[pod.epiccastle.bbssh.scp :as scp])
(let [session (bbssh/ssh "remote-host" {:username "remote-user"})]
;; execute
(-> (bbssh/exec session "echo 'I am running over ssh'" {:out :string})
deref
:out
println)
;; copy to remote
(scp/scp-to
;; multiple sources
[(io/file "single-file") ;; file
(io/file "directory") ;; directory
["content🚀" {:filename "string"}] ;; string data
[(byte-array [1 2 3 4])
{:filename "byte-array"}] ;; byte-array data
[(io/input-stream (byte-array [0xf0 0x9f 0x9a 0x80 0x00]))
{:filename "input-stream"
:size 5
}] ;; input stream
]
"remote-path" ;; remote path
{:session session ;; options
:recurse? true})
;; copy to local
(scp/scp-from "remote-path" "local-path" {:session session}))