Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ssh key by default #126

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:

## Use registered public SSH key(s)

By default anybody can connect to the tmate session. You can opt-in to install the public SSH keys [that you have registered with your GitHub profile](https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account).
By default only the user who has triggered the action can connect to the tmate session with [the SSH keys that are registered with the GitHub profile](https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account). You can opt-out of this by setting `limit-access-to-actor` to `false`

```yaml
name: CI
Expand All @@ -139,7 +139,7 @@ jobs:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
limit-access-to-actor: false
```

If the registered public SSH key is not your default private SSH key, you will need to specify the path manually, like so: `ssh -i <path-to-key> <tmate-connection-string>`.
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export async function run() {
}

let newSessionExtra = ""
if (core.getInput("limit-access-to-actor") === "true") {
if (core.getInput("limit-access-to-actor") !== "false") {
const { actor } = github.context
const octokit = new Octokit()

const keys = await octokit.users.listPublicKeysForUser({
username: actor
})
if (keys.data.length === 0) {
throw new Error(`No public SSH keys registered with ${actor}'s GitHub profile`)
throw new Error(`No public SSH keys registered with ${actor}'s GitHub profile, add an SSH key (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) or set \`limit-access-to-actor: false\` to allow anyone to connect without authentication.`)
}
const sshPath = path.join(os.homedir(), ".ssh")
await fs.promises.mkdir(sshPath, { recursive: true })
Expand Down