As long as you use the publication, you can send commands via ssh and copy files through scp . We use this to trigger some specific processes and publish some artifacts that cannot be carried through existing commands for various reasons.
You must carefully monitor which keys you use and which users you are addressing on the remote server. Often we use explicit -i arguments in ssh, and we always use explicit usernames to make sure everything goes as expected
ssh -i <key_path> <user>@<fqdn_host> <command>
If you do this in your script, everything will be fine. Of course, the key file should be readable by your Jenkins process, and you will need to make sure that the key is installed on both sides.
I also highly recommend using the built-in ssh controls to control:
- What hosts can use this key
- What commands can be used with this key
In particular, you can use the settings in ~/.ssh/authorized_keys on the host, which is the purpose of the ssh / scp command, to limit the hosts that can connect ( host= ), and even preload the command so that a particular key always only executes one specific command ( command= ).
For true adventures, you can specify command= and send commands to a limited shell command that restricts directory access or command access.
gaige source share