node 如何用shell进行scp传输?
 发布于 10 年前  作者 yuanzhhh  7465 次预览  最后一次回复是 10 年前  来自 问答 

如题,请大神支招~~~

16 回复
reverland

child_process…

reverland

@i5ting = =ssh库是啥意思

i5ting

@reverland scp是基于ssh协议的,so。。。

i5ting

@reverland 比如https://github.com/mscdex/ssh2

reverland

@i5ting child_process直接scp。。。

i5ting

@reverland 不行的,不信你试试,哈哈

reverland

@i5ting 额。。。明天试试。。。

yuanzhhh

@i5ting 昨晚试了下这个库https://github.com/spmjs/node-scp2 成功了~

yuanzhhh

@reverland 昨晚试了下这个库https://github.com/spmjs/node-scp2 成功了~

yuanzhhh

直接用的用户名:密码@地址:路径

i5ting

@yuanzhhh shipit就是这种原理

reverland

@i5ting 我这里可以

> fs.existsSync('/tmp/.zshrc');
false
> var scp = exec('scp $HOME/.zshrc reverland@localhost:/tmp/');
undefined
> fs.existsSync('/tmp/.zshrc');
true
i5ting

@reverland 你这是依赖scp命令的,哈哈

reverland

@i5ting 233就是这意思,还以为怎么回事。。。