# pw ssh

> Source: https://parallelworks.com/docs/cli/pw/ssh

## pw ssh

Initiate an SSH connection to a resource

### Synopsis

The **pw ssh** command initiates an SSH connection to a specific compute resource. The resource has to be running, and you must have SSH access to it.

Resource names can be specified in the following formats:
- **pw://username/name** - full format with explicit username
- **pw://name** - managed cluster by name in your organization
- **name** - short format where username defaults to your username

```
pw ssh <resource> [command] [flags]
```

### Examples

```
  # Interactively connect to a resource named 'my-resource' owned by you
  pw ssh my-resource
  
  # Interactively connect to a resource owned by another user
  pw ssh pw://Jake.Thayne/my-resource
  
  # Interactively connect to a managed cluster in your organization
  pw ssh my-managed-cluster
  pw ssh pw://my-managed-cluster
  
  # Interactively connect to your user workspace
  pw ssh workspace
  
  # Run the "hostname" command on a resource and exit
  pw ssh my-resource hostname
  
  # Run the "hostname" command on your user workspace and exit
  pw ssh workspace hostname
  
  # Connect to a node via a pw:// jump host (username defaults to resource username)
  pw ssh -J pw://Jake.Thayne/my-cluster 10.0.1.5
  
  # Connect to a node via a jump host with an explicit username
  pw ssh -J pw://Jake.Thayne/my-cluster alice@10.0.1.5
  
  # Run as a ProxyCommand for SSH
  ssh -i ~/.ssh/pwcli -o ProxyCommand="pw ssh --proxy-command %h" user@my-resource
  ssh -i ~/.ssh/pwcli -o ProxyCommand="pw ssh --proxy-command %h" user@pw://Jake.Thayne/my-resource
  ssh -i ~/.ssh/pwcli -o ProxyCommand="pw ssh --proxy-command %h" user@workspace
  
  # Run as a ProxyCommand for SSH, with port forward
  ssh -i ~/.ssh/pwcli -L 8080:localhost:80 -o ProxyCommand="pw ssh --proxy-command %h" user@my-resource
  ssh -i ~/.ssh/pwcli -R 80:localhost:8000 -o ProxyCommand="pw ssh --proxy-command %h" user@workspace
  
  # Run as a ProxyCommand for SCP
  scp -i ~/.ssh/pwcli -O -o ProxyCommand="pw ssh --proxy-command %h" file.txt user@my-resource:/home/user/file.txt
  scp -i ~/.ssh/pwcli -O -o ProxyCommand="pw ssh --proxy-command %h" file.txt user@workspace:/home/user/file.txt
```

### Options

```
  -h, --help                 help for ssh
  -J, --jump string          Connect to the target via a pw:// jump host (similar to ssh -J)
      --keepalive int        Interval in seconds between keepalive messages (0 to disable) (default 30)
  -L, --local stringArray    Forward local [bind_address:]port to remote host:hostport
      --proxy-command        Run as a proxy command for SSH or SCP
  -R, --remote stringArray   Forward remote [bind_address:]port to local host:hostport
  -X, --x11                  Enable X11 forwarding
```

### Options inherited from parent commands

```
      --context string         The context to use. Overrides PW_CONTEXT environment variable and current context from config.
      --platform-host string   The Parallel Works ACTIVATE platform host to use. Will override any other platform host settings.
  -v, --verbose                Enable verbose logging
```

### SEE ALSO

* [pw](/docs/cli/pw)	 - The Parallel Works ACTIVATE CLI
