# SSH agent connection

**URL:** <https://community.jenkins.io/t/ssh-agent-connection/7181>\
**Category:** Ask a question\
**Tags:** docker\
**Created:** [May 4, 2023, 8:26am UTC](https://community.jenkins.io/t/ssh-agent-connection/7181 "2023-05-04T08:26:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![respect99](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@respect99](https://community.jenkins.io/u/respect99)\
**Post date:** [May 4, 2023, 8:26am UTC](https://community.jenkins.io/t/ssh-agent-connection/7181/1 "2023-05-04T08:26:21Z")

</div>

Hello everyone,

I have a problem during creating a new node for the host on another docker which should be connected via ssh.

- Jenkins is hosted by docker jenkins/jenkins:latest
- Another docker container is centos7, (I named remote\_host)

1. So, I created ssh keys for both containers (Jenkins and remote\_host) with:  
ssh-keygen -t rsa (without password, just enter)

2. The next step it was to make sure that I can connect from Jenkins container to remote\_host without password.

Inside the Jenkins container.  
ssh-copy-id remote\_user@remote\_host

After entering a password, I tried to connect:  
ssh remote\_user@remote\_host (I successes to connect without a password)

1. On the Jenkins web platform _Dashboard/Manage Jenkins/Credentials_ created user:  
Username: remote\_user  
I enter the private key (id\_rsa) from remote\_host container

2. On the Dashboard/Manage Jenkins/ System I tried to check the connection on section SSH remote hosts  
Hostname: remote\_host  
Port: remote\_host  
Enter public key  
When I check, the result is: **Can’t connect to server**

3. Creating node  
Remote root directory: /home/remote\_user/  
Launch method: Launch agent via SSH  
Host: remote\_host  
Credentials: I choose remote\_user (wich early created)  
Host Key Verification Strategy: Known host verification strategy

After that, the agent can’t to be launched, result is:

```auto
SSHLauncher{host='remote_host', port=22, credentialsId='b03f16ca-d9a4-441d-9e95-9d34a164afee', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}

[05/04/23 08:25:27] [SSH] Opening SSH connection to remote_host:22. 
Searching for remote_host in /var/jenkins_home/.ssh/known_hosts Searching for remote_host:22 in /var/jenkins_home/.ssh/known_hosts

[05/04/23 08:25:37] [SSH] SSH host key matches key in Known Hosts file. 
Connection will be allowed. ERROR: Server rejected the 1 private key(s) for remote_user (credentialId:b03f16ca-d9a4-441d-9e95-9d34a164afee/method:publickey)
[05/04/23 08:25:37] [SSH] Authentication failed. Authentication failed. 
[05/04/23 08:25:37] Launch failed - cleaning up connection [05/04/23 08:25:37] [SSH] Connection closed.

```
