[Help]
Description of Problem
jenkins-cli not authenticating with provided ssh private key
Observed
when passing the jenkins-cli command:
java -jar ~/jenkins-cli.jar -s http://localhost:8080 -i ~/.ssh/ccdevops who-am-i
The console output is:
Authenticated as: anonymous
Authorities:
Desired
Jenkins should authenticate as the user with the matching public key in their profile
Relevant Information
jenkins v 2.46.3 and using the correct cli jar for the version
Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-78-generic x86_64)
only using recommend plugins
running on azure cloud in china east datacenter
azure network security group for the vm is configured to allow traffic
ssh key being used was created on the ubuntu machine jenkins is running on and the public key is in the users entry in the jenkins user database
Key was created using the instructions on the github site
jenkins-cli is running on the server and not from a remote host
Steps Tried Already
tried different keys with and without passphrases
tried the web address with localhost and the ip address
tried other jenkins-cli commands with same result
tried to create other users and putting an public ssh key in their profile. (no duplicate keys between users)
tried moving the location of the jenkins-cli jar from server root to jenkins home directory
You should also specify the SSH method and the user on the command line with -ssh and -user USER_NAME respectively. After that, your command would look like this:
java -jar ~/jenkins-cli.jar -s http://localhost:8080 -i ~/.ssh/ccdevops who-am-i -ssh -user USER_NAME
Also note that you'll need to be able to access the server via SSH as well.
Related
I am currently setting up a virtual machine for my company's testing environment in vagrant. Of course, this machine needs to be able to pull from our github repositories. This should be achieved using the host machine's ssh keys. I have already set
config.ssh.forward_agent = true
in my vagrantfile, and connecting to github works fine in the vagrant user. However, since that machine needs to run jenkins, this needs to work for the jenkins user as well. Running ssh-add as jenkins does not add the host's key, though.
I found several semi-related discussions here on stackoverflow and on superuser, but none seemed to address or even solve the issue. I have no idea how to make this work, or whether this is possible at all in vagrant, so I am grateful for any pointers.
As you have not included any exact errors and what you have tried,
Let's say you are on the VM, and you want to git pull from a remote git repo
You also have a ssh private key on the VM, that is authorized to pull from the git repo via ssh:
Try this on the VM's cli:
git config core.sshCommand 'ssh -i /root/.ssh/git_private.key -F /dev/null' && ssh-agent sh -c 'ssh-add /root/.ssh/git_private.key; git pull'
and of course reference the correct path to the private ssh key that you would use to auth to git repo
I ran su command to switch to root. Using default password: vagrant.
From there su jenkins - switching user to jenkins, no password this time.
ran ssh-keygen - to generate the keys. Stored them in the default folder suggested: /var/lib/jenkins/ (actually overwrote the existing ones). That is the home folder of this jenkins user, because it is not a regular user/account, but so called "service account" I believe.
After that I just uploaded that .pub key to my bitbucket account, and everything ran fine, my jenkins could authenticate.
I would like to deploy a set of docker containers on a remote docker host using docker-compose -H ssh://user#host up
This works fine as I added my default public key (~/.ssh/id_rsa.pub) to the remote hosts authorized_keys
But how can I specify an alternative private key? Is there an option like when using ssh: ssh -i /path/to/key user#host ?
Background: I would like to trigger a docker-compose deployment on a remote Host using Jenkins. I created a Jenkins Credential of the Kind "SSH Username with private key". Using the credentials plugin I can also get a hold of the key using something like
withCredentials([sshUserPrivateKey(credentialsId: 'some.id', keyFileVariable: 'PKEY')]) {
// $PKEY points to temp. available key file
}
But I don't know how I could pass that to docker-compose -H ...
Or is there a way not to use a key and prompt for the password with a similar mechanism as in docker login --password-stdin?
How do I configure SSH connections in jenkins, when I have an intermediate bastion with its own user and key like this:
Host jump
User user1
HostName jumpdns
IdentityFile /Users/myname/.ssh/jumpkey.pem
Host server
User user2
HostName serverdns
IdentityFile /Users/myname/.ssh/serverkey.pem
ForwardAgent yes
ProxyJump jump
This works on cli as ssh server. But I dont know how to encode that into my jenkins that is running locally in my laptop from within my user and not as a separate jenkins user ie. JENKINS_HOME=/Users/myname/.jenkins
I looked into Publish over SSH plugin and it does provide for a jumpdns option but not jump's own user and key. And it seems like others have been been looking for it without a solution.
What is the best way to configure Jenkins for my SSH setup?
Assuming you are on jenkins version: 2.303.2. This is the latest version as of now.
If your master has a SSH version(OpenSSH_7.4p1 for example) which supports jump host option then you can try this:
-Select Launch method as 'Launch agent via execution via execution of command on controller'
-Launch command: ssh -tt -J user#jump_host_name user#destination_host
https://www.tecmint.com/access-linux-server-using-a-jump-host/
I am a newbie to Mesos. I have installed a DCOS cluster locally in one system (Centos 7).
Everything went up properly and I am able to access the GUI of DCOS but when I am trying to connect through CLI, it is asking me for password.
I have not been prompted for any kind of password during local installation through vagrant.
But when I issue the following command:
[root#blade7 dcos-vagrant]# dcos node ssh --master-proxy --leader
Running `ssh -A -t core#192.168.65.90 ssh -A -t core#192.168.65.90 `
core#192.168.65.90's password:
Permission denied, please try again.
core#192.168.65.90's password:
I don’t know the password to be given.
Kindly help me in resolving this issue
Since the local installation bases on vagrant, you can use the following convenient workaround: directly log into the virtual machines by using vagrant's ssh.
open a terminal and enter vagrant global-status to see a list of all running vagrant environments (name/id)
switch into your dcos installation directory (e.g., cd ~/dcos-vagrant), which contains the file Vagrantfile
run vagrant ssh <name or (partial) id> in order to ssh into the virtual machine. For example, vagrant ssh m1 connects to the master/leader node, which gives you essentially the same shell as dcos node ssh --master-proxy --leader would do.
Two more tips:
within the virtual machine, the directory /vagrant is mounted to the current directory of the host machine, which is nice for transferring files into/from the VM
you may try to find out the correct ssh credentials of the default vagrant user and then add these (rather than the pem file retrieved from a cloud service provider) via ssh-add to your host machine. This should give you the ability to login via dcos node ssh --master-proxy --leader --user=vagrant without a password
The command shows that you are trying to login to the server using the userid "core". If you do not know the password of user "core", I suggest reset "core" user password and try it again.
I set up Neo4j on an EC2 instance using this
http://www.neo4j.org/develop/ec2
I have the SSH key so I can SSH into the instance, but I don't remember the password I set up for the web interface. I believe this is a Jetty basicauth equivalent, but I'm not sure, nor could I find the config files that might lead me to the right place. How can I reset this password?
`neo4j-server.properties´ has a setting for the auth-extension being used by the puppet script:
org.neo4j.server.credentials=<user>:<pass>
I'm not sure where neo4j-server.properties is located on your machine, check /etc/neo4j or use find / -name neo4j-server.properties.
You can reset neo4j web interface password by following these steps, provided you have SSH access to ec2 instance:
Login to ec2 instance from your local console:
ssh -i [your-key] ubuntu#[ec2-instance-ip]
login as superuser sudo su
Remove auth file from var/lib/neoj/data/dbms
rm -f var/lib/neoj/data/dbms/auth
Reset the password by running
neo4j-admin set-initial-password secret
Restart neo4j: systemctl restart neo4j
You can access neo4j web interface from browser with username as neo4j and new password.