Execute Shell Script on remote host using SSH - jenkins

I am new to Jenkins and existing job uses Execute Shell script on the remote host using SSH in the Build. In the SSH Site, there is a lot of username#ip in the drop-down box so that the developer can select the SSH site and build.
Now, my requirement is to add an IP to the SSH Site. I am not authorized to install plugins. How to add an IP to the SSH Site to the existing set of IP's?

new ssh sites are added from jenkins global configuration under ssh hosts.
Manage Jenkins--> SSH hosts --> Add new site
Hope this answers your questions

You can add SSH remote in latest Jenkins version in this way
Dashboard -> Manage Jenkins -> Configure System -> SSH remote hosts -> Add

Related

want to add a jenkins slave as a different user say "UserX"

I have logged-in to Jenkins UI using my Unix credentials (pmandal).
Then I have added a slave node (Slave1).
Now when i "Launch slave", it tries to ssh from the MASTER to the Slave(Slave1) as "jenkins" USER, and ssh fails.
My requirement is: I want the ssh from the MASTER to the Slave as a different user say "UserZ", coz i want all my operations to be performed as UserZ.
But i am unable to do so.
So my main question here is : "How to i make the MASTER to ssh to the Slave as UserZ"?
Any help would be appreciated.jenk
create the credentials in jenkins store.
This can be done from https://<yourjenkins.url>/credentials/store/system/domain/_/newCredentials
connect the node with the option "launch agent agents via ssh jenkins". From the config page of the node, you can select the credentials you just created
Note: the option "launch agent agents via ssh jenkins" is the recommended way to connect unix/linux machines: https://support.cloudbees.com/hc/en-us/articles/115003929412-How-to-create-an-agent-in-Linux-from-console

Jenkins SSH Agent Plugin shows empty drop down in Jenkins Job

I am using SSH Agent Plugin version 1.17 with Jenkins version 2.190.3
When I create credentials using
Jenkins -> Credentials -> System -> Global credentials (unrestricted) -> Add Credentials
But when I create jenkins job type Freestyle project, I don't see credentials in ssh agent drop down.
Please advise what I am missing
Ref:
https://wiki.jenkins.io/display/JENKINS/SSH+Agent+Plugin
https://support.cloudbees.com/hc/en-us/articles/360029470091-How-to-use-the-SSH-Agent-Plugin
Jenkins plugin ssh-agent showing "ERROR: Failed to run ssh-add"
Update:
Issue is open for credentials (username/password) https://issues.jenkins-ci.org/browse/JENKINS-59807
but good thing is that it works with private key :)
You have to select Kind as SSH Username with private key to be able to specific use credentials in ssh agent:

Jenkins deployment on GCP VM via shell script

I'm new to Google Cloud Platform and want to build a deployment pipeline via Jenkins. I have a virtual machine up and running that I connect via SSH button given on the dashboard and do deployments.
Unlike AWS where I get pem file to connect... I don't have a file to connect here. Now, in Jenkins when I want to connect via shell script and deploy latest code on VM - I don't know how to do it.
something like
ssh -i #some-file name:ip
Kindly help as to how can I connect/ssh gcp vm via shell in Jenkins and make deployments. Step by step answer needed. Thanks!
There are still PEM files stored in the VM instance, you can locate them in $HOME/.ssh.
See this stack post about how to retrieve SSH keys on GCE

Jenkins - Master Slave set up questions

I followed tutorial to get Jenkins set up on Windows.
What i have is:
Jenkins running with recommend plugins installed
Jenkins URL changed to http:// my ipv4:8080/
A project with a simple command [echo hi]
For nodes i currently have just the Master node which is tied to my main PC
My goal is have one computer send a command to all the slave PC's so they run a python script i created.
I create a windows VM and connected to the Jenkins server. I logged in with the admin account and created a new node.
I cant find anything useful to help me figure out what to put in launch command. When i launch my node on the VM without the launch command specified, it fails to launch.
Is the batch script i wrote in the project, what's sent to all the slave machines or do I have this all wrong?
Thank you!
EDIT
I got it working thanks to the answer posted here. I wrote up a doc on how i got Jenkins working from installation to deployment. There are other resources out there but i hope this will help someone.
Jenkins Master/Agent Setup
If you want to have the option Launch slave agents via Java Web Start you should specify the TCP port for slaves.
It is done through Manage Jenkins > Configure Global Security > TCP port for JNLP agents. You can select fixed port 50000. More info here.

Jenkins Remote Deployments

We're trying to setup Jenkins, but we are having a couple issues.
We have a "Jenkins Server" (Master) and have connected it to Fisheye. Jenkins is able to get the Git repo and run the tests.
Is there some kind of built in process for Jenkins to give it capabilites to SSH into a server and run commands like "git pull origin master" ?
Yes there is ssh capabilities in Jenkins. You can add a build step for either running SSH or sending files over SSH (you have to define target server in config). Theres also a post build plugin for sending artifacts over ssh which can be used to also execute remote commands.
I'd recommend a book by John Smart which covers Jenkins setup. Its at http://www.wakaleo.com/books/jenkins-the-definitive-guide
I think you want the SSH Plugin for Jenkins. This will let you define SSH servers in your global configuration, and then define commands to be run before and after the build.

Resources