# SSH Connection \[AUTH FAIL\]

**URL:** <https://community.jenkins.io/t/ssh-connection-auth-fail/4121>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [October 10, 2022, 6:19am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121 "2022-10-10T06:19:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharun456](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@tharun456](https://community.jenkins.io/u/tharun456)\
**Post date:** [October 10, 2022, 6:19am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/1 "2022-10-10T06:19:36Z")

</div>

Hi Team  
Recently an domain migration has happened.It changed from x to y.  
When i try to check ssh connection getting auth fail.Error is pasted below  
jenkins.plugins.publish\_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [badlavserverUAT]. Message [Auth fail]].  
Note: Telnet is able to reach from jenkins server to destination server.  
2.ssh is configured using username and passoword.

Please help with any solution .Thanks

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [October 10, 2022, 7:05am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/2 "2022-10-10T07:05:25Z")

</div>

Hello Tharun,

Does the ssh connection work from a terminal?

---

<div class="post-metadata">

**Author:** ![tharun456](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@tharun456](https://community.jenkins.io/u/tharun456)\
**Post date:** [October 10, 2022, 7:55am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/3 "2022-10-10T07:55:19Z")

</div>

Getting this error ssh -p 22 user@host  
Permission denied (publickey,keyboard-interactive).

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [October 10, 2022, 8:08am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/4 "2022-10-10T08:08:08Z")

</div>

Are you using a key to log in (I guess so)?  
Could you try to specify the key to use in order to login?  
Something like:

```auto
ssh -i deployment_key.txt -p 22 user@host

```

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [October 11, 2022, 7:33am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/5 "2022-10-11T07:33:35Z")

</div>

I would recommend looking at the logs of the ssh server to see why it’s failing.

---

<div class="post-metadata">

**Author:** ![codeorion](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@codeorion](https://community.jenkins.io/u/codeorion)\
**Post date:** [November 21, 2022, 1:11pm UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/6 "2022-11-21T13:11:41Z")

</div>

Same issue.

SSH connect work from terminal but Jenkins can’t connect

- there are 2 containers in docker compose:
  - jenkins
  - remote\_host

- there are 2 keys:
  - id\_rsa3
  - id\_rsa3.pub

- when connect to jenkins container via:
  - docker exec -it jenkins bash  
and try:
  - ssh -i id\_rsa3 a12@remote\_host → it can connect without password

- but when I configure same Jenkins SSH with this id\_rsa3:
  - Can’t connect to server

SSH was generate by: ssh-keygen -t rsa -m PEM -f id\_rsa3  
LOGS from Jenkins show → Auth fail and Can’t connect to server

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [November 21, 2022, 4:31pm UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/7 "2022-11-21T16:31:27Z")

</div>

would still recommend looking at the sshd logs on the target server. They’ll tell you a lot about why a login request was rejected. Its likely you pasted the wrong ssh keys into credentials

---

<div class="post-metadata">

**Author:** ![codeorion](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@codeorion](https://community.jenkins.io/u/codeorion)\
**Post date:** [November 23, 2022, 6:25am UTC](https://community.jenkins.io/t/ssh-connection-auth-fail/4121/8 "2022-11-23T06:25:04Z")

</div>

True. This advide was very helpfull. When I check remote\_host logs I saw: “key type ssh-rsa not in PubkeyAcceptedAlgorithms”. After I create ssh-key in this way: ssh-keygen -t ecdsa -m PEM -f id\_rsa3 - connect started working.  
Looks like the issue was related to this topic: Ubuntu 22.04 SSH the RSA key isn’t working since upgrading from 20.04.
