I am stuck to configure publish over ssh in jenkins.
Jenkins container to ansible container in CLI I am able to do SSH via private key, but the same private key when I am using on publish over ssh it does not work.
jenkins.plugins.publish_over.BapPublisherException: Failed to connect
and initialize SSH connection. Message: [Failed to connect session for
config [ansible]. Message [USERAUTH fail]]
I solved this problem yesterday morning. In the ssh configuration file I added two lines, now working perfectly.
PubkeyAuthentication yes
PubkeyAcceptedKeyTypes=+ssh-rsa
Related
Jenkins SSH server showing mentioned error Algorithm negotiation fail while trying to set up with over the SSH plugin when trying to connect over ssh to a local server (Linux Container). I am able to connect using ssh on the terminal.
jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [anisbleHOST]. Message [Algorithm negotiation fail]]
Ubuntu machine - auth.log
Unable to negotiate with xx.xx.xx.x port 39866: no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 [preauth]
tried with the mentioned below sshd_config values but no luck.
HostKeyAlgorithms ssh-ed25519-cert-v01#openssh.com,ssh-ed25519
KexAlgorithms curve25519-sha256#libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
To resolve the above-mentioned issue first I made changes to /etc/ssh/sshd_config and regenerated RSA keys using ssh-keygen. Jenkins doesn't support keys generated using ed25519.
My New sshd_config -
HostKeyAlgorithms ssh-rsa-cert-v01#openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostCertificate /etc/ssh/ssh_host_key-cert.pub
KexAlgorithms diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,ecdh-sha2-nistp256,ecdh-sha2-nistp384
PubkeyAcceptedKeyTypes ssh-rsa,ssh-rsa-cert-v01#openssh.com,ssh-ed25519-cert-v01#openssh.com,ssh-ed25519
TrustedUserCAkeys /etc/ssh/ssh_user_ca.pub
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
LogLevel DEBUG
Please UPVOTE if it helps you :)
I'm trying to connect to Windows agent use SSh(Launch agent agents via SSH)
Jenkins master(in Linux)
log:
[SSH] Opening SSH connection to 192.168.0.122:22.
[SSH] SSH host key matches key seen previously for this host. Connection will be allowed.
ERROR: Server rejected the 1 private key(s) for my_bot (**********)
[SSH] Authentication failed.
Authentication failed.
Launch failed - cleaning up connection
[SSH] Connection closed.
I tried to add key to authorized_keys.. but it did not help
When ssh says "SSH host key" it means the keys in known_hosts.
Check .ssh/known_hosts to see that key.
Although "Connection will be allowed" implies this is not a problem for you.
So ignore that part of the error message.
Your real problem is "ERROR: Server rejected the 1 private key"...
Is they key exchanged ok?
Private key needs to be in jenkins. Also check file permissions.
Public key needs to be on server side. Probably .ssh/authorized_keys. Also check file permissions. Ssh will not allow keys to be used if permissions on .ssh or files contained inside are too open.
More information is needed to help solve the question:
In your question please show the ssh command you use - the full command - do you specify key with -i parameter ?
From jenkins command-line, can you ssh to the host using the same ssh command ?
Do ls -al on jenkins home .ssh dir and on server side .ssh dir to check permissions.
To get more verbose/debug information add -v or -vv or -vvv to your ssh command.
Also look at ssh logs on server side if possible.
In your question you could tidy up the log messages.
Same error seen on this question here and I can see they did chown 744 .ssh/authorized_keys in dockerfile which is the wrong way to set permissions for an authorized_keys file.
https://superuser.com/questions/1403715/why-i-am-getting-error-server-rejected-the-1-private-key-error-on-setting-up-s/1443503#1443503
i am encountering a weird issue when adding a new jenkins slave node.
the steps that i have done are as followed:
copied the public key from the master to the slave authorized_keys
checked that i can connect from the master to the slave to make sure it works
created keys on the slave and copied them to the new credentials.
getting the following error
picture of the error
further more, when i use the private key from the server to connect to it
ssh -i <path to private key> user#ip
gives me the same error
Permission denied (publickey).
but when i connect without the argument (with my public key) then it works.
regarding your step 3 - are you saying that you are saving the slave private key in jenkins credentials? It should be the master private key you should have in your jenkins credentials and use that to connect to your slave.
you have to trust the key, in jenkins you have to select manually trusted key while adding the private key, then below that you have to check the check box for trusting the key, after saving that you'll get on the option to trust the host's key in nodes dash board.
I configured capitrano to deploy a Rails app from Git bash on Windows. I created one rsa key to connect to the remote server with the user deploy and another rsa key to connect to bitbucket with my account.
Before deploying I set up the ssh-agent with both keys.
When deploying I have an authentication failed (publickey error) nevertheless when I try to ssh deploy#myserver.com it works and from inside my server if I try git -T git://bitbucket.org it connects and show me my username.
How can I debug this issue?
The issue was that the ssh client used by capitrano doesn't handle ssh-agent on Windows. The solution was to use Pageant the agent of the putty project but before importing keys to pageant they have to be converted to the ppk format by puttykeygen
I'm just starting out with jenkins and I'm having trouble to connect to a remote machine via rsync.
I guess jenkins doesn't know which ssh identity file to use or maybe it knows, but doesn't know how to decrypt it? From other questions i gathered that the Gtk-Warning is probably because it can't open the "enter keyphrase"-prompt.
rsync -azvh /var/lib/jenkins/workspace/ofen sascha#my_server:/my_project/ofen
No protocol specified
(ssh-askpass:19928): Gtk-WARNING **: cannot open display: :0
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]
Everything works fine when I try it from commandline.
Need to have the key loaded as part of Jenkin's SSH Agent configuration.
Add the private key to Jenkins via credentials/SSH private key including pass phrase if one is used
Enable SSH agent on the job and give it the credential
Things that use SSH keys and agents can now use the loaded key.
The "identity" depends on where your job is running:
when running on the master, it's the user that runs Jenkins
on a slave, it's the user that you use for connecting the slave
You need to add the public key of that identity to the .ssh/authorized_keys file of user sascha. This will enable public key-based authentication and rsync should run just fine.