Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

docker - How to scp something with public key in azure-pipelines?

My azure pipeline contains compiling of a project and building docker image from it.

Now I want to copy this image to target machine and run it there.

With shell script what I was doing is:

sudo docker build -f src/main/docker/Dockerfile.jvm -t $docker_name .
sudo docker save $docker_name > $tar_name

scp $tar_name $target_path

I think I did build and save parts in azure-pipelines already.

But how to do scp? I need some ssh key in pipeline to authorize it on target machine. It's can't be my key pair since it will be compromised. How to make one for pipeline then?


Here is the task description. It states, that

The task supports use of an SSH key pair to connect to the remote machine(s).

But doesn't explain, how to use key pair if I have it.

question from:https://stackoverflow.com/questions/66060420/how-to-scp-something-with-public-key-in-azure-pipelines

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found Azure has special pipeline task called CopyFilesOverSSH. It receives key in the form of pre-configured "Service connection", which should be configured on seprate page:

enter image description here

Configuring service connection involves storing keys correctly.

There is no need to call scp command itself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...