Giter Site home page Giter Site logo

google / chrome-ssh-agent Goto Github PK

View Code? Open in Web Editor NEW
236.0 11.0 33.0 3.09 MB

SSH Agent for use with Google Chrome's Secure Shell extension

License: Apache License 2.0

Go 86.49% HTML 1.07% CSS 0.60% Shell 1.08% Starlark 8.71% TypeScript 2.05%
chrome-extension ssh-agent

chrome-ssh-agent's Introduction

test status

SSH Agent for Google Chrome™

This is a bare-bones SSH agent extension for Google Chrome™. It provides an SSH agent implementation that can be used with the Secure Shell Chrome extension.

Getting Started

Installation

Install the extension from the Chrome Web Store.

Adding and Using Keys

  1. Click on the SSH Agent extension's icon in to Chrome toolbar. List keys
  2. Configure a new private key by clicking the 'Add Key' button. Give it a name and enter the PEM-encoded private key. Add key If you use Chrome Sync, configured keys will be synced to your account and available across your devices. Only the raw PEM-encoded private key you entered will be synced. That is, if you entered an encrypted private key, the encrypted private key will be synced. If you entered an unencrypted private key, the unencrypted private key will be synced.
  3. Click the 'Load' button and enter the key's passphrase to load the key into the SSH agent. Enter passphrase
  4. When creating a new connection in the Secure Shell extension, add --ssh-agent=eechpbnaifiimgajnomdipfaamobdfha to "SSH Relay Server Options" field to indicate that it should use the SSH Agent for keys. Connect

Credits

Portions of the code and approach are heavily based on the MacGyver Chrome extension. In particular, the following:

  • Usage of GopherJS, which makes it easy to use Go's existing SSH Agent implementation.
  • Code translating between the SSH Agent protocol used by the secure Shell extension and the actual SSH agent protocol (details).

Disclaimer

This is not an officially supported Google product.

chrome-ssh-agent's People

Contributors

dependabot[bot] avatar ralimi avatar renovate-bot avatar rpwoodbu avatar testwill avatar vapier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chrome-ssh-agent's Issues

Feature request: use hardware backed storage for keypair

This agent extension would be a great place to add support for "Keychains" to Secure Shell.

The user could import (and bind for hardware backing) a certificate in Chrome's store (chrome://settings/certificates) and the extension would access those using the chrome.platformKeys API.

I guess the X.509 certificate would have to contain dummy information as only the public and private key are useful. The extension could help with generating the certificate for import by converting the OpenSSH keypair.

An additional way to support hardware backed keys would be through Smart Cards, similar to how OpenSSH's agent can use a PKCS11 module.
I'm guessing this agent extension would need to implement a middleware for the Smart Card Connector extension.

SSH Agent Forwarding?

This is not really an issue, but maybe a feature request or just a request for documentation. I was curious if it's possible to do ssh agent forwarding with this?

If so, how?

If not, is that something that could be added?

Thank you!

'vet' target fails with gopherjs vendored

When gopherjs is vendored, 'make vet' fails with the following error:

vetting code
go/agentport/io.go:32:2: cannot find package "github.com/gopherjs/gopherjs/js" in any of:
/home/ralimi/gocode/src/github.com/google/chrome-ssh-agent/vendor/github.com/gopherjs/gopherjs/js (vendor tree)
/usr/lib/go-1.10/src/github.com/gopherjs/gopherjs/js (from $GOROOT)
/home/ralimi/gocode/src/github.com/gopherjs/gopherjs/js (from $GOPATH)
Makefile:55: recipe for target 'vet' failed
make: *** [vet] Error 1

For now, 'make vet' is no longer executed by default.

Disable sync for private keys?

Kinda missing the point of the "private" in "private key" if the key is synchronised to all of my Chrome-using devices.

Security Policy violation Binary Artifacts

This issue was automatically created by Allstar.

Security Policy Violation
Project is out of compliance with Binary Artifacts policy: binaries present in source code

Rule Description
Binary Artifacts are an increased security risk in your repository. Binary artifacts cannot be reviewed, allowing the introduction of possibly obsolete or maliciously subverted executables. For more information see the Security Scorecards Documentation for Binary Artifacts.

Remediation Steps
To remediate, remove the generated executable artifacts from the repository.

Artifacts Found

  • vendor/github.com/gopherjs/gopherjs/node-syscall/build/Release/obj.target/syscall.node
  • vendor/github.com/gopherjs/gopherjs/node-syscall/build/Release/obj.target/syscall/syscall.o
  • vendor/github.com/gopherjs/gopherjs/node-syscall/build/Release/syscall.node

Additional Information
This policy is drawn from Security Scorecards, which is a tool that scores a project's adherence to security best practices. You may wish to run a Scorecards scan directly on this repository for more details.


Allstar has been installed on all Google managed GitHub orgs. Policies are gradually being rolled out and enforced by the GOSST and OSPO teams. Learn more at http://go/allstar

This issue will auto resolve when the policy is in compliance.

Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.

Nothing to click -- to start a session

I tried this on Windows 10 and OSX 10.13. Click on the button, load the key and that's all it does.
There is no link in the window as shown to start a session
screen shot 2018-11-27 at 8 42 47 pm

mosh extension support

hello friends,

many thanks to you for this great extension.
it's working great with ssh extension ssh.
I'd like to also use it in mosh sessions of the same ssh extension, but i don't see how to do that.
please help or instruct.

thank you in advance,
alex

Upgrade to Bazel 7

Builds under Bazel 7 failed when executed under Github's action runners.

The underlying errors were:

ERROR: /home/runner/.cache/bazel/_bazel_runner/b5ea0b3c9d34e2d5dd9018c7508d45aa/external/_main~chromium_dependencies~chromedriver/BUILD.bazel:2:8: declared output 'external/_main~chromium_dependencies~chromedriver/chromedriver.bin' is a dangling symbolic link
ERROR: /home/runner/.cache/bazel/_bazel_runner/b5ea0b3c9d34e2d5dd9018c7508d45aa/external/_main~chromium_dependencies~chromedriver/BUILD.bazel:2:8: Executing genrule @@_main~chromium_dependencies~chromedriver//:chromedriver failed: not all outputs were created or valid

This issue tracks upgrading to Bazel 7 and not pinning to a specific version.

No support for SSH Certificates

In my setup, the SSH keys alone are not sufficient for authentication, if not accompanied with a SSH certficate. With OpenSSH, certificates are automatically loaded into the ssh-agent after calling ssh-add, that means there are two entries in the agent listing:

$ ssh-add -l
2048 SHA256:sARrpIfvcA+WXiGe209WuUiqOB7zyA7zdxmHGjfqiYU [email protected] (RSA)
2048 SHA256:sARrpIfvcA+WXiGe209WuUiqOB7zyA7zdxmHGjfqiYU [email protected] (RSA-CERT)

It would be nice if loading of SSH certificates was supported by this Chrome app as well.

Add validation that _test.go files have no build tags

Go files that are part of a go_library rule have a build tag that causes them to be ignored unless being built under WebAssembly. Unfortunately, if the build tag is present in tests, the test will silently be skipped.

To avoid this, consider writing a nogo check that _test.go files have no build tags.

Protect BigStorage operations with a mutex

Implement a mutex around BigStorage operations to prevent cleaning up chunks that may be referenced.

This is now technically possible since Delete() is no longer an atomic operation; it deletes keys, then cleans up dangling chunks.
However, dangling chunks may be newly-referenced if Set() is invoked at the same time as Delete().

This is unlikely given that this is only done in the Options UI, but we should more systematically prevent it.

We can consider the Web Locks API.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

bazel-module
MODULE.bazel
  • rules_go 0.46.0
  • gazelle 0.36.0
  • rules_nodejs 6.1.0
  • aspect_rules_js 1.40.1
  • aspect_rules_ts 2.2.0
  • aspect_rules_esbuild 0.19.0
  • bazel_skylib 1.5.0
  • rules_pkg 0.10.1
  • rules_proto 6.0.0-rc1
bazelisk
.bazelversion
  • bazel 7.1.1
github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • actions/setup-go v5
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/release-beta.yml
  • actions/checkout v4
  • bazelbuild/setup-bazelisk v3
  • softprops/action-gh-release v2
  • mnao305/chrome-extension-upload v5.0.0
.github/workflows/release.yml
  • actions/checkout v4
  • robinraju/release-downloader v1.9
  • mnao305/chrome-extension-upload v5.0.0
.github/workflows/test.yml
  • actions/checkout v4
  • bazelbuild/setup-bazelisk v3
  • actions/cache v4
gomod
go.mod
  • go 1.22.2
  • github.com/google/go-cmp v0.6.0
  • github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a@1326539a0a0a
  • golang.org/x/crypto v0.22.0
  • github.com/bazelbuild/rules_go v0.46.0
  • github.com/chromedp/cdproto v0.0.0-20240328024531-fe04f09ede24@fe04f09ede24
  • github.com/chromedp/chromedp v0.9.5
  • github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd@106a353d42dd
  • golang.org/x/tools v0.20.0
npm
package.json
  • @ungap/url-search-params ^0.2.2
  • jsdom ^24.0.0
  • mem-storage-area ^1.0.3
  • web-locks ^0.0.8
  • @types/chrome ^0.0.265
  • typescript ^5.4.4
regex
MODULE.bazel
  • golang 1.22.2
  • chrome 125.0.6403.0

  • Check this box to trigger a request for Renovate to run again on this repository

Revert to default NodeJS version selection

Updating to Go 1.21 due to the following dependency chain:

Thus, we have to wait until a version of aspect_rules_js that defaults to rules_nodejs >= 6.0.0.

For now, we can manually override to use NodeJS 18. This issue tracks reverting to the default.

Make Manager.Unload() accept an ID

Manager.Unload() currently accepts a reference to a loaded key (public key, key type). This is somewhat clunky to handle internally, and results in a few edge cases. It would be cleaner to just accept the ID directly.

IIRC, the original intent was to enable unloading keys that the extension didn't load in the first place. However, we don't currently allow that on the UI, and the extension generally isn't positioned to consistently manage keys loaded outside the extension (e.g., directly from a client) anyways. For example, see #25.

ssh agent not used for WASM ssh connections

When the secure shell extension runs as WASM code instead of PNACL code, which it seems to do occasionally, the ssh agent code does not work to provide authentication for the ssh connection. This results in being prompted for a password, when the public key is not offered to the remote ssh server.

I use the secure shell extension regularly, as well as the ssh-agent extension to provide authentication. Whenever the secure shell tries to run its WASM version, the ssh agent code is not running. I am requesting the use of this extension by adding the following to the ssh relay server option box:
--ssh-agent=eechpbnaifiimgajnomdipfaamobdfha

Client-added keys not persisted past Service Worker restart

Chrome is requiring all extensions to move to Manifest V3 in Chrome, which means using Service Workers instead of a persistent background page.
Service Workers have the Chrome will forcibly suspend them after some time (see https://bugs.chromium.org/p/chromium/issues/detail?id=1152255). This means the instance of the Agent is destroyed, losing all of its loaded keys.

We can list the loaded keys, but we only get back Key instances which (understandably) do not contain the private key material. This makes it impossible for us to save them to be added back when the Service Worker restarts.

For keys loaded via the extension's UI, this is fine since our code loads them to the agent. We store the private key unencrypted in memory in chrome.storage.session (which is fine since the private key was in the Agent anyways), which allows us to add it back when the Service Worker restarts.

However, then a connected ssh client adds a key to the agent, we don't see the private key, and hence have no way to restore it.

Feature Request: Confirm constraint

It would be great to support the confirm mechanism that exists in the SSH agent protocol.

Currently when loading a key through ssh-add with the -c option, the key will actually be used silently without any prompt.

I looked through the golang crypto source code, and it looks like the agent server parses the constraint and sets a ConfirmBeforeUse flag on the key, but the keyring.add method simply ignores it.

From a UI persepective, I'd want the options page to set the constraint when adding a key and / or when loading it.
For the prompt, the extension could show a notification (with require interaction set), to ask to either confirm or deny.

Consistently release js.Func objects

We invoke js.FuncOf() to construct callbacks that are invoked as event listeners. In cases where they are one-time events, we invoke Release() when the callback is complete. However, in cases where the callback may be invoked many times, we don't call Release() and we need to find a different way to clean them up appropriately.

CrOS Terminal app is not allowlisted

The ChromeOS / ChromiumOS builtin Terminal app gained SSH capability many releases ago, built on the same libraries as the Secure Shell extension.

Per Terminal app maintainer, it does not have a manifest ID, however it should be possible to allowlist using:

  "externally_connectable": {
    "matches": [
      "chrome-untrusted://terminal/html/terminal_ssh.html*"
    ]
  }

I'll send a pull request for this shortly.

"Failed to load key...."

Starting this afternoon, I'm seeing this error message:

image

failed to load key: failed to decrypt key: key marshalling failed: x509: unknown key type while marshaling PKCS#8: *ed25519.PrivateKey*

I think there's a new version out, right? Something seems broken.

Edit: to clarify, I see this message when I try to load an existing key (which was loaded and worked this morning!).

Thanks.

ed25519 keys don't load

My ed25519 ssh key doesn't seem to load. I think this started with the Aug 12 2022 release- this key has worked fine for a long time but now fails.

Steps:

  • Open extension and press "load" for an ed25519 key (public key starts with ssh-ed25519)
  • Enter correct passphrase

Expected:

  • Key loads. This has worked correctly for a long time.

Actual:

  • Load fails with an error message "failed to load key: failed to decrypt key: key marshalling failed: x509: unknown key type while marshaling PKCS#8: *ed25519.PrivateKey"

I tried entering the wrong passphrase and got a different error ("failed to load key: failed to decrypt key: failed to parse private key: x509: decryption password incorrect") so I'm pretty sure my passphrase is correct.

This is on a ChromeOS device.

  • Chrome Version 104.0.5112.83 (Official Build) (64-bit)
  • Extension version 0.0.20

Show 'Loading' indicator on Options UI

When the Options page loads, the list of keys is initially blank, and there is no indication that it is fetching them in the background.

If this is on the slower side, it can be somewhat worrying for the user, as they may think that their keys have been removed/forgotten.

Does not work with ECDSA keys

I'm able to add the key through the UI, but when trying to 'load' it, it keeps asking for a password, even when key is unencrypted.

If I use ssh-add on a remote session, the key is added to the agent, but is seems like the key is lost later / not synced.

These keys can be generated using ssh-keygen -t ecdsa -b 521, as one would expect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.