# How to SSH access

**URL:** <https://community.localwp.com/t/how-to-ssh-access/464>\
**Category:** Support\
**Created:** [January 10, 2017, 3:45pm UTC](https://community.localwp.com/t/how-to-ssh-access/464 "2017-01-10T15:45:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinmamaqi](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/kevinmamaqi/32/4446_2.png) [@kevinmamaqi](https://community.localwp.com/u/kevinmamaqi)\
**Post date:** [January 10, 2017, 3:45pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/1 "2017-01-10T15:45:18Z")

</div>

How can I access to individual sites via SSH? - In order to use WP-CLI

---

<div class="post-metadata">

**Author:** ![clay](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/clay/32/8248_2.png) [@clay](https://community.localwp.com/u/clay)\
**Post date:** [January 10, 2017, 3:48pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/2 "2017-01-10T15:48:52Z")

</div>

You can SSH in by right-clicking on the site in the sidebar then going to `Open Site SSH` 😃

After doing that you can immediately use `wp` without changing directories.

---

<div class="post-metadata">

**Author:** ![kevinmamaqi](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/kevinmamaqi/32/4446_2.png) [@kevinmamaqi](https://community.localwp.com/u/kevinmamaqi)\
**Post date:** [January 10, 2017, 4:05pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/3 "2017-01-10T16:05:48Z")

</div>

Perfect. Thank you.

---

<div class="post-metadata">

**Author:** ![soderlind](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/soderlind/32/24675_2.png) [@soderlind](https://community.localwp.com/u/soderlind)\
**Post date:** [February 15, 2017, 6:18pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/4 "2017-02-15T18:18:51Z")

</div>

Guess this is a FAQ question, @clay how can I access a site using ssh, but not using the Local application, ie not right-clicking the site but doing: ssh root@mysite.dev

what’s the username and password I should use ?

---

<div class="post-metadata">

**Author:** ![raison](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/raison/32/4445_2.png) [@raison](https://community.localwp.com/u/raison)\
**Post date:** [May 14, 2017, 4:35pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/5 "2017-05-14T16:35:37Z")

</div>

+1 Need to ssh into - whats the password?

---

<div class="post-metadata">

**Author:** ![litpro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/litpro/32/4726_2.png) [@litpro](https://community.localwp.com/u/litpro)\
**Post date:** [June 2, 2017, 9:14pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/6 "2017-06-02T21:14:22Z")

</div>

There appears to be no password. Local runs its wordpress components in docker containers, and makes a script for each container that does “docker exec -it [docker-container-id] /bin/bash” to allow you to execute commands on them.

---

<div class="post-metadata">

**Author:** ![clay](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/clay/32/8248_2.png) [@clay](https://community.localwp.com/u/clay)\
**Post date:** [August 23, 2017, 4:48pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/7 "2017-08-23T16:48:28Z")

</div>

5 posts were split to a new topic: [Running PHPUnit in PhpStorm with Local](https://community.localwp.com/community/t/running-phpunit-in-phpstorm-with-local/2670)

---

<div class="post-metadata">

**Author:** ![soderlind](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/soderlind/32/24675_2.png) [@soderlind](https://community.localwp.com/u/soderlind)\
**Post date:** [September 18, 2017, 1:15pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/8 "2017-09-18T13:15:07Z")

</div>

Learned [how to log into the Local machine](http://www.theaveragedev.com/developing-a-local-addon-01/#logging-into-the-virtual-machine):

`ssh -i ~/.docker/machine/machines/local-by-flywheel/id_rsa docker@192.168.94.100`

You’ll find the IP-address in Local-\>Database dashboard

---

<div class="post-metadata">

**Author:** ![mitchrosefelt](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mitchrosefelt](https://community.localwp.com/u/mitchrosefelt)\
**Post date:** [September 24, 2017, 11:59am UTC](https://community.localwp.com/t/how-to-ssh-access/464/9 "2017-09-24T11:59:20Z")

</div>

Edit after re-reading the thread…  
Anyone recommend a SSH for Win10?  
Thanks.

---

<div class="post-metadata">

**Author:** ![clay](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/clay/32/8248_2.png) [@clay](https://community.localwp.com/u/clay)\
**Post date:** [September 25, 2017, 2:22pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/10 "2017-09-25T14:22:03Z")

</div>

Hi @mitchrosefelt,

Can you please explain what you’re trying to do?

If you right-click on the site in Local’s sidebar then go to “Open Site SSH” it should open it up in Cmd automatically. 🙂

---

<div class="post-metadata">

**Author:** ![Keith](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@Keith](https://community.localwp.com/u/Keith)\
**Post date:** [October 5, 2017, 1:23am UTC](https://community.localwp.com/t/how-to-ssh-access/464/12 "2017-10-05T01:23:26Z")

</div>

right click to get ssh only works if your default shell is bash. (if you are using fish it doesn’t work)

---

<div class="post-metadata">

**Author:** ![crs1138](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/crs1138/32/4444_2.png) [@crs1138](https://community.localwp.com/u/crs1138)\
**Post date:** [March 1, 2018, 8:09am UTC](https://community.localwp.com/t/how-to-ssh-access/464/13 "2018-03-01T08:09:13Z")

</div>

wp-cli offers a global parameter **–ssh=** what do I write after that to gain access for wp-cli in my shell to a site on Local?

```
--ssh=[<scheme>:][<user>@]<host\|container>[:<port>][<path>]
Perform operation against a remote server over SSH 
(or a container using scheme of “docker”, “docker-compose”, “vagrant”).
```

---

<div class="post-metadata">

**Author:** ![ben.turner](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/ben.turner/32/5366_2.png) [@ben.turner](https://community.localwp.com/u/ben.turner)\
**Post date:** [March 2, 2018, 7:18pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/14 "2018-03-02T19:18:01Z")

</div>

Hey guys, the reason there isn’t a straightforward answer to give is that these are all Docker containers, but we don’t have you install Docker on the host machine such that it is accessible to your `$PATH`.

You can tease out what exactly is happening when you are right-clicking and "Open Site SSH"ing by opening the file that is reported in the terminal.

Here’s a screenshot of two terminals I have open, one from clicking Open Site SSH, and one where I open the bash script that the first terminal executed:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/lwpforums/original/2X/d/d8084c078bc9272eb14cf41540ce0625a274accf.png)

Since this is a bash script, that’s why right-clicking within Local won’t work with Fish – this is just a bash script.

When I open that script, there are instructions for connecting to the site’s specific Docker machine:

```auto
export DISABLE_AUTO_TITLE="true"
echo -n -e "\033]0;newblank SSH\007"
eval $("/Users/benjamin/Applications/Local by Flywheel.app/Contents/Resources/extraResources/virtual-machine/vendor/docker/osx/docker-machine" env local-by-flywheel);
"/Users/benjamin/Applications/Local by Flywheel.app/Contents/Resources/extraResources/virtual-machine/vendor/docker/osx/docker" exec -it d78472ef6d4f9a4dd1dda96c7a41f94bffad69c60435ec5dff8f0461a379ce09 /bin/bash;

```

You can break this down into something more easy to understand:

```auto
eval $('...' env local-by-flywheel);

```

This line sets up the terminal session to use the Docker environment that’s running within the `local-by-flywheel` VM.

```auto
".../docker" exec -it <container_id> /bin/bash;

```

This line is using the environment we set up in the previous line to create an interactive, teletype terminal running bash.

To your specific question @crs1138 – I haven’t tried this, but you might be able to install Docker so that it’s accessible to your `$PATH` and then execute commands directly against the container hash found in that bash file.

I think that it would look something like:

1. Install Docker: `brew cask install docker`
2. Ensure the Local VM is running, and then make Docker use that environment: `eval $(docker-machine env local-by-flywheel)`
3. Docker commands – for example `docker ps` to list the running containers.

If you try this out, let me know what you find!

– Ben

---

<div class="post-metadata">

**Author:** ![crs1138](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/crs1138/32/4444_2.png) [@crs1138](https://community.localwp.com/u/crs1138)\
**Post date:** [March 2, 2018, 10:13pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/15 "2018-03-02T22:13:12Z")

</div>

Hi Ben, this is is what I got…

```
 eval $(docker-machine env local-by-flywheel)
 docker ps
 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
 e9cb6d4b4a08 flywheel:1.1 "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp youthful_pare
 2db760ae1612 custom:1.2 "/etc/scripts/sleep.…" 5 weeks ago Up 2 minutes 0.0.0.0:4008->80/tcp, 0.0.0.0:4009->443/tcp, 0.0.0.0:4011->1080/tcp, 0.0.0.0:4010->3306/tcp trusting_lovelace
 2ec093e05eae custom:1.2 "/etc/scripts/sleep.…" 8 weeks ago Up 2 minutes 0.0.0.0:4012->80/tcp, 0.0.0.0:4013->443/tcp, 0.0.0.0:4015->1080/tcp, 0.0.0.0:4014->3306/tcp naughty_jackson

```

WTF is naughty\_jackson or trusting\_lovelace? 😳🤪😂

---

<div class="post-metadata">

**Author:** ![clay](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/clay/32/8248_2.png) [@clay](https://community.localwp.com/u/clay)\
**Post date:** [March 2, 2018, 10:20pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/16 "2018-03-02T22:20:35Z")

</div>

> [@crs1138](#):
>
> WTF is naughty\_jackson or trusting\_lovelace?

Haha, those are some interesting ones!

Now that you have the container IDs, you can “SSH” into the first one using the `custom:1.2` image by running `docker exec -it 2db760ae1612 /bin/bash`.

---

<div class="post-metadata">

**Author:** ![crs1138](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/crs1138/32/4444_2.png) [@crs1138](https://community.localwp.com/u/crs1138)\
**Post date:** [March 2, 2018, 10:26pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/17 "2018-03-02T22:26:04Z")

</div>

How do I use that with the `wp-cli --ssh=` flag?

---

<div class="post-metadata">

**Author:** ![ben.turner](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/ben.turner/32/5366_2.png) [@ben.turner](https://community.localwp.com/u/ben.turner)\
**Post date:** [March 7, 2018, 1:09am UTC](https://community.localwp.com/t/how-to-ssh-access/464/18 "2018-03-07T01:09:35Z")

</div>

Great @crs1138 – after you setup the environment for the terminal session:

```auto
eval $(docker-machine env local-by-flywheel)

```

You should be able to reference the naughty\_jackson site using that container id:

```auto
wp post list --ssh='docker:2ec093e05eae' --allow-root

```

You’ll need the `--allow-root` part since within the container, the processes are being executed as root.

It still gets odd with file permissions and such, but that should be enough for you to be dangerous 🙂

---

<div class="post-metadata">

**Author:** ![Back2Front](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/back2front/32/1434_2.png) [@Back2Front](https://community.localwp.com/u/Back2Front)\
**Post date:** [April 20, 2018, 7:36am UTC](https://community.localwp.com/t/how-to-ssh-access/464/19 "2018-04-20T07:36:14Z")

</div>

Trying to work out how to set up [serveo.net](http://serveo.net) to ssh into the docker container -

something like  
ssh -R ~/.docker/machine/machines/local-by-flywheel/id\_rsa [docker@192.168.95.100](mailto:docker@192.168.95.100) [serveo.net](http://serveo.net)

any clues?

Trying to use [serveo.net](http://serveo.net) + autossh to create more persistent tunnel addresses than [ngrok.io](http://ngrok.io), collaborators are sick of tunnel addresses changing each time reboot.

---

<div class="post-metadata">

**Author:** ![jasontheadams](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/jasontheadams/32/6811_2.png) [@jasontheadams](https://community.localwp.com/u/jasontheadams)\
**Post date:** [December 27, 2018, 7:26pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/20 "2018-12-27T19:26:13Z")

</div>

It’s a bummer. This used to work for me some of the time, and now it doesn’t work anymore. I’ve used the long method of connecting that ben.turner provided, which I appreciate, but it seems like this just hasn’t been a reliable function of Local for quite some time. It’s a very important feature, too.

Can this please get some attention from Flywheel?

---

<div class="post-metadata">

**Author:** ![jasontheadams](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/jasontheadams/32/6811_2.png) [@jasontheadams](https://community.localwp.com/u/jasontheadams)\
**Post date:** [December 28, 2018, 6:11pm UTC](https://community.localwp.com/t/how-to-ssh-access/464/21 "2018-12-28T18:11:36Z")

</div>

After doing some digging, I think I found where the problem is happening. Hopefully this will help the Local team to fix the issue, and others to throw together a workaround much easier than described above.

When you right-click on a site and go to “Open Site SSH” it opens your terminal and runs a command. If you’re like me, the command closes prematurely. If you’re in iTerm it throws and error and closes the tab. If you use Terminal, it will leave it open and state that it’s closed.

The line to look out for here is something like the following:

```auto
/Users/jason/Library/Application\ Support/Local\ by\ Flywheel/ssh-entry/r1uSme9kV.sh; exit;

```

The `ssh-entry` directory contains a bunch of bash scripts for the respective sites. Each script does all the heavy lifting to identify the site’s container and connect to it via docker. In my case, the site I’m trying to connect to is `r1uSme9kV.sh`.

What’s odd here is that the script is immediately followed by `exit;`. It seems like the bash script runs asynchronously (or is using asynchronous command). If the docker connection isn’t made in time, the `exit;` command runs and closes the shell. If it happens to work fast enough, it connects.

So if you execute the file directly, without the `exit;` command, it works great! In my case, I made a `ssh-local-container.sh` file in my project that has only the following:

```auto
/Users/jason/Library/Application\ Support/Local\ by\ Flywheel/ssh-entry/r1uSme9kV.sh

```

And just like that, it connects every time.

* * *

I suppose the big question for the Local team is why they included the `exit;` command after executing the bash script? Omitting that seems to resolve the issue, and if connecting to docker works then it ignores the command.

Hope this helps! 🙂

[Next page](https://community.localwp.com/t/how-to-ssh-access/464.md?page=2)
