
https://godoc.org/github.com/appleboy/drone-scp?status.svg](https://godoc.org/github.com/appleboy/drone-scp) 
通过SSH协议复制文件和制品的工具,支持在二进制、Docker或Drone CI环境中使用。
以下为网络拓扑示例:
sh+--------+ +----------+ +-----------+ | 电脑 | <--> | 跳转主机 | <--> | 目标服务器 | +--------+ +----------+ +-----------+ 或 +--------+ +----------+ +-----------+ | 电脑 | <--> | 防火墙 | <--> | 目标服务器 | +--------+ +----------+ +-----------+ 192.168.1.5 121.1.2.3 10.10.29.68
v1.5.0:将命令超时标志更改为Duration类型。配置示例如下:
diffpipeline: scp: 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
预编译二进制文件可从https://github.com/appleboy/drone-scp/releases%E4%B8%8B%E8%BD%BD%E3%80%82%E6%94%AF%E6%8C%81%E4%BB%A5%E4%B8%8B%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%B1%BB%E5%9E%8B%EF%BC%9A
若已安装Go环境,可通过以下命令安装:
shgo get -u -v github.com/appleboy/drone-scp
或使用以下命令构建二进制文件:
shexport 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镜像:
shmake docker
有三种发送文件的方式:
使用公钥
bashdrone-scp --host example.com \ --port 22 \ --username appleboy \ --key-path "${HOME}/.ssh/id_rsa" \ --target /home/appleboy/test \ --source your_local_folder_path
使用密码
diffdrone-scp --host example.com \ --port 22 \ --username appleboy \ + --password xxxxxxx \ --target /home/appleboy/test \ --source your_local_folder_path
使用ssh-agent
启动本地ssh代理:
basheval `ssh-agent -s`
导入本地公钥~/.ssh/id_rsa:
shssh-add
无需添加--password或--key-path参数:
bashdrone-scp --host example.com \ --port 22 \ --username appleboy \ --target /home/appleboy/test \ --source your_local_folder_path
发送多源、多目标文件夹或多主机
diffdrone-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
使用公钥
bashdocker run --rm \ -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
使用密码
diffdocker 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
使用ssh-agent
启动本地ssh代理:
basheval `ssh-agent -s`
导入本地公钥~/.ssh/id_rsa:
shssh-add
无需添加SCP_PASSWORD或SCP_KEY_PATH参数:
bashdocker 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
发送多源、多目标文件夹或多主机
bashdocker 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
在工作目录中执行:
bashdocker 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
有关如何在Drone中使用scp的更多信息,请参见插件文档。
使用以下命令测试包:
shmake test
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。




探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务