如何使用SSH密钥使用bitbucket管道将angular production build部署到外部服务器?
我们正在尝试使用Bitbucket管道将基本angular应用程序部署到Google云上的VM,但不确定如何使用SSH密钥连接到服务器以复制构建文件。正在查找示例,但找不到 我们可以使用Putty/SSH命令手动复制dist文件 我们从Google云的VM中获得了公钥/私钥,并将它们添加到Bitbucket Pipelines>SSH密钥中 我们的YML脚本如下:如何使用SSH密钥使用bitbucket管道将angular production build部署到外部服务器?,angular,bitbucket-pipelines,Angular,Bitbucket Pipelines,我们正在尝试使用Bitbucket管道将基本angular应用程序部署到Google云上的VM,但不确定如何使用SSH密钥连接到服务器以复制构建文件。正在查找示例,但找不到 我们可以使用Putty/SSH命令手动复制dist文件 我们从Google云的VM中获得了公钥/私钥,并将它们添加到Bitbucket Pipelines>SSH密钥中 我们的YML脚本如下: image: node:6.9.4 pipelines: default: - step: cache
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- npm install
- npm install -g @angular/cli@1.6.4
- ng build --prod
- cd dist/
- ssh -i ???
image: node:8
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
#- echo "$(ls -la)"
- npm install
- npm install -g @angular/cli
- ng build --prod
- echo "$(ls -la dist/)"
- scp -r dist/ user@1.2.3.4:/home/suren/temp
正如@Chris所说的那样,很有可能会派上用场,这是正确的起点。
步骤如下:
ssh-keygen
cat~/.ssh/my_ssh_key.pub|sshusername@remote_host“mkdir-p~/.ssh&&touch~/.ssh/authorized_keys&&chmod-R go=~/.ssh&&cat>~/.ssh/authorized_keys”
`ssh-copy-id -i my_ssh_key username@remote_host`
scpusername@remote_host:/path/to/file/path/to/destination
我们能够通过以下方式解决此问题:
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- npm install
- npm install -g @angular/cli@1.6.4
- ng build --prod
- cd dist/
- ssh -i ???
image: node:8
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
#- echo "$(ls -la)"
- npm install
- npm install -g @angular/cli
- ng build --prod
- echo "$(ls -la dist/)"
- scp -r dist/ user@1.2.3.4:/home/suren/temp
- 添加私钥和公钥以及
- 添加已知主机(这将是您要将代码推送到的服务器的IP地址。在我们的示例中,这是Google云上的VM)
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- npm install
- npm install -g @angular/cli@1.6.4
- ng build --prod
- cd dist/
- ssh -i ???
image: node:8
pipelines:
default:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
#- echo "$(ls -la)"
- npm install
- npm install -g @angular/cli
- ng build --prod
- echo "$(ls -la dist/)"
- scp -r dist/ user@1.2.3.4:/home/suren/temp
在bitbucket管道上,我们需要使用在远程主机上生成的公钥。用截图更新了我的问题。