# Mender-Artifact SSH Connection with IdentityFile

**URL:** <https://hub.mender.io/t/mender-artifact-ssh-connection-with-identityfile/5036>\
**Category:** General Discussions\
**Tags:** mender-artifact, ssh\
**Created:** [June 20, 2022, 12:56pm UTC](https://hub.mender.io/t/mender-artifact-ssh-connection-with-identityfile/5036 "2022-06-20T12:56:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bfelsera](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bfelsera](https://hub.mender.io/u/bfelsera)\
**Post date:** [June 20, 2022, 12:56pm UTC](https://hub.mender.io/t/mender-artifact-ssh-connection-with-identityfile/5036/1 "2022-06-20T12:56:05Z")

</div>

Hey there,  
hopefully someone can give me advice how to use the `--ssh-args` option when creating a Mender artifact from an golden image.

So I want to create a golden image from a remote device via SSH and using `mender-artifact` for this. The device SSH remote connection can just be established via an SSH Keyfile which works fine during default SSH connection and the `-i PATH_TO_IDENTITYFILE` parameter, for example:  
`ssh -i PATH_TO_IDENTITY_FILE USERNAME@IPv4`

For `mender-artifact` I need to set the `Identity File` by the `--ssh-args="-o IdentityFile=PATH_TO_IDENTITY_FILE` parameter but this won’t work because mender-artifact says that the key file doesn’t exist.  
Also adding an additional option `IdentitiesOnly=yes` shows the same error.

Can you help me by enterring a complete command for SSH remote connection via SSH Keyfile?

Complete command with output:  
`mender-artifact write rootfs-image -f ssh://USER@IPv4 -n NAME --software-version SOFTWARE_VERSION -o file.mender -t TYPE --ssh-args="-o IdentityFile=PATH_TO_IDENTITY_FILE" --ssh-args="-o IdentitiesOnly=yes" no such identity: PATH_TO_IDENTITY_FILE: No such file or directory USER@IPv4: Permission denied (publickey). SSH error: Error waiting for ssh session to be established.: EOF `

Thanks.  
Andreas

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://hub.mender.io/u/peter)\
**Post date:** [June 20, 2022, 3:09pm UTC](https://hub.mender.io/t/mender-artifact-ssh-connection-with-identityfile/5036/2 "2022-06-20T15:09:51Z")

</div>

Hello Andreas,

thank you for using Mender.  
I have copied your command:

```bash
# [-f /home/my-user/.ssh/id_rsa] && echo it is there
it is there
# mender-artifact write rootfs-image -f ssh://username@hostname -n NAME --software-version SOFTWARE_VERSION -o file.mender -t TYPE --ssh-args="-o IdentityFile=/home/my-user/.ssh/id_rsa" --ssh-args="-o IdentitiesOnly=yes"
0% 50% 100%
|---------------------------------|---------------------------------|
.....

```

and as you can see it started making the artifact. Could you verify that you supply the absolute path to an existing identity file?

best regards,  
peter

---

<div class="post-metadata">

**Author:** ![bfelsera](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bfelsera](https://hub.mender.io/u/bfelsera)\
**Post date:** [June 20, 2022, 6:12pm UTC](https://hub.mender.io/t/mender-artifact-ssh-connection-with-identityfile/5036/3 "2022-06-20T18:12:12Z")

</div>

Hello Peter,

thanks a lot for your response and the hint with the first `echo` command.  
Sometimes this typo issues are just for users who trying things on Monday… 😉

Wish you all the best,  
Andreas

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://hub.mender.io/u/peter)\
**Post date:** [June 21, 2022, 12:57pm UTC](https://hub.mender.io/t/mender-artifact-ssh-connection-with-identityfile/5036/4 "2022-06-21T12:57:16Z")

</div>

Hello Andreas,

thank you 🙂  
that is why I start on Tuesdays 🙂  
great to hear it is working for you.

have a good week,  
peter
