通過SSH自動同步文件或目錄:sshync
通過SSH自動同步文件或目錄,使用 fs.watch().
配有一個極好的工具sshpair生成一個公共SSH密鑰。
echo -e "y\n" | ssh-keygen -q -N "" -f ~/.ssh/sshync
and writes the result to~/.ssh/authorized_keyson the remote host. This prevents the password prompt from showing up every time we sync.
Ignore paths by adding them, one per line, to a file named.sshyncignorein the providedsourcefolder.
安裝
$ npm install sshync -g
使用
# generate a public SSH key (so we don't have to retype password) # write to user@ip:~/.ssh/authorized_keys $ sshpair <user@ip[:port]> # initialize file auto-sync $ sshync <user@ip[:port]> <source> <destination> source: local source folder. destination: remote destination folder.
示例
$ git clone https://github.com/mateogianolio/sshync.git $ cd sshync $ sshpair root@xxx.xxx.82.203 generated ssh key to ~/.ssh/sshync.pub root@xxx.xxx.82.203's password: root@xxx.xxx.82.203's password: ~/.ssh/sshync.pub => ~/.ssh/authorized_keys $ echo -e ".git\nnode_modules" > .sshyncignore $ sshync root@xxx.xxx.82.203 . /root/sshync . => root@xxx.xxx.82.203:/root/sshync ignore ./.sshyncignore mkdir -p /root/sshync [+] ./README.md => /root/sshync/README.md [399 bytes] [+] ./package.json => /root/sshync/package.json [520 bytes] [+] ./sshync.js => /root/sshync/sshync.js [3304 bytes] [+] ./LICENSE.md => /root/sshync/LICENSE.md [1084 bytes] # ... edit package.json ... [/] ./package.json => /root/sshync/package.json [524 bytes]
本文由用戶 xdld 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!