# SSH to container fails with: sh: $(if \[ -f /usr/bin/balena \]

**URL:** <https://forums.balena.io/t/ssh-to-container-fails-with-sh-if-f-usr-bin-balena/7344>\
**Category:** balenaOS\
**Created:** [May 7, 2019, 2:14am UTC](https://forums.balena.io/t/ssh-to-container-fails-with-sh-if-f-usr-bin-balena/7344 "2019-05-07T02:14:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![webtop](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/webtop/32/1994_2.png) [@webtop](https://forums.balena.io/u/webtop)\
**Post date:** [May 7, 2019, 2:14am UTC](https://forums.balena.io/t/ssh-to-container-fails-with-sh-if-f-usr-bin-balena/7344/1 "2019-05-07T02:14:54Z")

</div>

Issue trying to SSH into container from running on RPi2 from Windows 10 machine, possibly related to:

> [@Resin local ssh on win10: "syntax error near unexpected token \`then'"](https://forums.balena.io/t/resin-local-ssh-on-win10-syntax-error-near-unexpected-token-then/3066/12):
>
> Hi pimterry, I’m using win10, and so far I was trying with plain cmd, and git bash. Cmd fails with errormsg, but git bash has no feedback. Here is the error from cmd:

When attempting from same environment (Win10, Git Bash, MinGW64), I get:

> ```
> $ balena local ssh balena-rpi2-dev.local --container main_1_1
> sh: -c: line 0: syntax error near unexpected token `then'
> sh: -c: line 0: `$(if [-f /usr/bin/balena]; then echo \"balena\"; else echo \"docker\"; fi) exec -ti main_1_1 /bin/sh -c $\'if [-e /bin/bash]; then exec /bin/bash; else exec /bin/sh; fi'"'
> Connection to balena-rpi2-dev.local closed.
> 
> ```

But when I try to connect via PowerShell, I get:

> ```
> PS C:\WINDOWS\system32> balena local ssh 192.168.0.17 --container main_1_1
> sh: $(if [-f /usr/bin/balena]; then echo "balena"; else echo "docker"; fi): No such file or directory
> Connection to 192.168.0.17 closed.
> 
> ```

I can ssh into the host with no problem at all, but not the container.

> root@balena-rpi2-dev:~# balena-engine version  
> Client:  
> Version: 17.12.0-dev  
> API version: 1.35  
> Go version: go1.9.7  
> Git commit: dceb2fc48071b78a8a828e0468a15a479515385f  
> Built: Thu Jan 17 15:08:33 2019  
> OS/Arch: linux/arm  
> Experimental: false  
> Orchestrator: swarm
> 
> Server:  
> Engine:  
> Version: 17.12.0-dev  
> API version: 1.35 (minimum version 1.12)  
> Go version: go1.9.7  
> Git commit: dceb2fc48071b78a8a828e0468a15a479515385f  
> Built: Thu Jan 17 15:08:33 2019  
> OS/Arch: linux/arm  
> Experimental: true

balena-cli version is 10.8.0

Any thoughts?

---

<div class="post-metadata">

**Author:** ![hedss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hedss/32/210_2.png) [@hedss](https://forums.balena.io/u/hedss)\
**Post date:** [May 7, 2019, 2:08pm UTC](https://forums.balena.io/t/ssh-to-container-fails-with-sh-if-f-usr-bin-balena/7344/3 "2019-05-07T14:08:35Z")

</div>

Hi @webtop,

Thanks for letting us know there’s an issue. There’s a duplicate thread here: [SSH connection to device in local mode fails](https://forums.balena.io/t/ssh-connection-to-device-in-local-mode-fails/7348/10)

We’ve posted a workaround (although it looks like you can get into the host, which means you should be able to use this), and the relevant engineer has been contacted. When we have more information, we’ll certainly update you all.

Best regards, Heds

---

<div class="post-metadata">

**Author:** ![webtop](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/webtop/32/1994_2.png) [@webtop](https://forums.balena.io/u/webtop)\
**Post date:** [May 7, 2019, 4:27pm UTC](https://forums.balena.io/t/ssh-to-container-fails-with-sh-if-f-usr-bin-balena/7344/5 "2019-05-07T16:27:49Z")

</div>

Thanks Heds 🙂
