An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward calls to open

Overview

Remote Development Manager

An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward calls to open. RDM works by listening on a unix socket locally that can be forwarded to an SSH session.

So far the server only works on macOS, but the client commands are not OS specific.

Installation

The easiest way to install rdm is to download the latest release for your platform. Alternatively, you can build it yourself with go build main.go.

e.g. for a Linux server you can use wget to download the binary then put it somewhere in your $PATH:

wget https://github.com/BlakeWilliams/remote-development-manager/releases/download/latest/rdm-linux.amd64
mv rdm-linux.amd64 /usr/local/bin/rdm
chmod +x /usr/local/bin/rdm

Usage

The following is an example of forwarding an rdm server to a remote host: ssh -R 127.0.0.1:7391:$(rdm socket) [email protected]. It's worth noting the port number is not currently configurable and will always attempt to connect to 7391.

Server commands:

  • rdm server - hosts a server locally (macOS only) so that your machine can receive copy, paste, and open commands.
  • rdm close - attempts to close a running server.
  • rdm logpath - returns the path where server logs are located. Useful for tail $(rdm logpath)
  • rdm socket - returns the path where the server socket lives. Useful for SSH commands, as seen above.

Client commands:

  • rdm copy - reads stdin and forwards the input to the host machine, adding it to the clipboard. e.g. echo "hello world" | rdm copy
  • rdm paste - reads and prints the host machine's clipboard. rdm paste
  • rdm open - forwards the first argument to open. e.g. rdm open https://github.com/blakewilliams/remote-development-manager

TO-DO

So far this is just an experiment and there's a lot to be done to get it to a stable point. Contributions are very welcome.

  • Add test coverage
  • Daemonize the server process
  • Add a configuration file that allows custom commands
Comments
  • Remote vim paste with rdm does not work as expected

    Remote vim paste with rdm does not work as expected

    Hey @BlakeWilliams 👋🏻

    I found an issue with my vim copy/paste config. Perhaps the issue is not in vim, but in rdm.

    To illustrate, say I am on codepsaces, in a vim buffer with the following content:

    one two three
    four five
    six seven
    

    I am in normal mode, and my cursor is on the "f" from "five". I type yw (yank word), and that should copy the word "five". Then I type P to paste before my cursor, and this is the expected result:

    one two three
    four fivefive
    six seven
    

    But this is the actual result:

    one two three
    five
    four five
    six seven
    

    It seems like copy behaves as if I had done a yy, or Y (copy line).

    This is my vim config:

    https://github.com/mjacobus/dotfiles/blob/3f60925fe661e8e12ddf27a4c235cda4ba849efe/neovim/.config/nvim/config.vim#L403-L410

    " Forward clipboard in a codespace
    if !empty($CODESPACES)
      let g:clipboard = {"name": "rdm", "copy": {}, "paste": {}}
      let g:clipboard.copy["+"] = ["rdm", "copy"]
      let g:clipboard.paste["+"] = ["rdm", "paste"]
      let g:clipboard.copy["*"] = ["rdm", "copy"]
      let g:clipboard.paste["*"] = ["rdm", "paste"]
    endif
    

    Also I played with rdm outside vim, to see if I found any clue.

    image

    I will dig some more later, and share what I found.

    opened by mjacobus 3
  • Support linux

    Support linux

    This adds support for running rdm server on linux machines by:

    • replacing macos-specific clipboard and URL-opening commands with an abstraction and using build constraints to select the correct implementation. Specifically pbcopy/pbpaste becomes xclip and open becomes xdg-open. One advantage of this approach is that the binary now only builds on platforms where it is capable of running.
    • fixing a path concatenation bug that caused illegal log paths to be generated.

    Cheers!

    edit: By request, 47d1953b2ace26f89856f08ab12a707fa53045c9 also introduces a new interface for all OS-specific functionality. I called it ~hostservice.Service~ hostservice.Runner with a default implementation called hostservice.HostService.

    opened by brasic 2
  • docs: how to configure Neovim clipboard with Lua

    docs: how to configure Neovim clipboard with Lua

    Hi!

    I love RDM, it has improved my workflow with codespaces a lot and it was easy and simple to use. Thanks a lot for writing it!

    This PR adds a small snippet to the docs explaining how to configure the clipboard on Neovim using Lua instead of VimL.

    I've extracted it form my own dotfiles: https://github.com/franciscoj/dotfiles/blob/8ab7f992e00f076a5ed8b238d48524aef0ed3dbd/dot_config/nvim/lua/options.lua#L65-L77

    Cheers!

    opened by franciscoj 1
  • Delete socket file when server isn't running

    Delete socket file when server isn't running

    Sometimes the server dies without removing the socket file. When this happens the server will fail to start even though there is no running server.

    Instead of failing immediately, the server command now attempts to talk to the server running on the socket. If it succeeds, it exits since a server is already running. If it fails, it removes the socket file and starts the server.

    opened by BlakeWilliams 0
  • Properly support reading stdin

    Properly support reading stdin

    Currently we read from stdin and always append a newline due to scanner.Scan splitting on newlines. This isn't always correct, since input doesn't always have a newline.

    This resolves the issue by using bufio.Reader.ReadBytes which reads up-to the delimiter and includes it, preserving newlines.

    Fixes https://github.com/BlakeWilliams/remote-development-manager/issues/6

    opened by BlakeWilliams 0
  • Make remote detection more reliable

    Make remote detection more reliable

    Sometimes SSH_TTY and SSH_CLIENT aren't set when in an ssh session, so this checks three different potential environment variables that indicate you're in a remote session.

    • SSH_TTY
    • SSH_CLIENT
    • SSH_CONNECTION
    opened by BlakeWilliams 0
  • Migrate from custom socket proto to http

    Migrate from custom socket proto to http

    Given how the initial spike turned out there wasn't much value using a socket directly so this replaces the custom protocol with HTTP since JSON is the message format either way.

    opened by BlakeWilliams 0
  • Add launchd daemon support for macos

    Add launchd daemon support for macos

    This adds a new service subcommand that sets up rdm to run as a launchd service on MacOS.

    $ rdm service
    Manage this program as a launchd system service.
      Status of gui/501/com.blakewilliams.rdm:
        Install state: [Installed]
        Run state:     [Running]
    
    Usage:
      rdm service [command]
    
    Available Commands:
      install     Configures rdm to run on boot as a MacOS LaunchAgent.
      start       Starts the launchd service.
      stop        Stops the launchd service.
      uninstall   Removes a previously installed LaunchAgent installation.
    
    Flags:
      -h, --help   help for service
    
    Use "rdm service [command] --help" for more information about a command.
    

    Here's a quick demo:

    asciicast

    I originally wrote all the launchd management plumbing in this PR but after a while I realized it was kind of unrelated to this project so I spun it into a new library at https://github.com/brasic/launchd.

    opened by brasic 0
  • socket connection refused after sleeping with rdm server left running

    socket connection refused after sleeping with rdm server left running

    :wave: Hello! This utility greatly improves the quality of my life, thanks for making it and sharing it!

    I've run into a rough edge that I'd thought I'd capture in an issue.

    While having a running rdm server in the background, I close my laptop. When I open the laptop again, the rdm server is unreachable.

    In a codespace, I'll try to view a PR on github and get the following:

    % gh pr view --web
    Opening <snip> in your browser.
    2022/09/14 14:03:41 Can not send command: could not send command: Post "http://unix///tmprdm.sock": dial unix /tmprdm.sock: connect: no such file or directory
    

    If I check on my host machine (macOS) and try to to stop the running server, I get the following error:

    ~ % rdm stop
    2022/09/14 10:03:50 Can not send command: could not send command: Post "http://unix///var/folders/5n/c1kfd01d4p50ddx07vn0zbl40000gn/T/rdm.sock": dial unix /var/folders/5n/c1kfd01d4p50ddx07vn0zbl40000gn/T/rdm.sock: connect: connection refused
    ~ % rm -rf /var/folders/5n/c1kfd01d4p50ddx07vn0zbl40000gn/T/rdm.sock
    ~ % rdm server &
    [1] 11953
    ~ %
    

    My current solution is to rm -rf <path to the socket> and restart the server. It would be great if the server could persist, or if it stopped itself when the machine went into a state where the socket gets "lost" (I know almost nothing about unix sockets or what might be happening).

    If you're open to it, I might try to put a PR together in my spare time as a project to start learning go, but I will be very slow to do this 🕺

    opened by gnfisher 9
  • Add custom commands

    Add custom commands

    • Adds custom commands that can be run from the client on the server process
    • Adds process manager so processes can (eventually) be managed if they are marked as long running.

    TO-DO:

    • [x] Add tests
    • [x] Support long running commands (rdm ps, rdm kill)
    opened by BlakeWilliams 0
Releases(v0.0.5)
Owner
Blake Williams
staff engineer working on performance @github
Blake Williams
Display (Namespace, Pod, Container, Primary PID) from a host PID, fails if the target process is running on host

Display (Namespace, Pod, Container, Primary PID) from a host PID, fails if the target process is running on host

K8s-school 13 Oct 17, 2022
CetusGuard is a tool that allows to protect the Docker daemon socket by filtering the calls to its API endpoints.

CetusGuard CetusGuard is a tool that allows to protect the Docker daemon socket by filtering the calls to its API endpoints. Some highlights: It is wr

Héctor Molinero Fernández 5 Dec 23, 2022
⚡️ A dev tool for microservice developers to run local applications and/or forward others from/to Kubernetes SSH or TCP

Your new microservice development environment friend. This CLI tool allows you to define a configuration to work with both local applications (Go, Nod

Vincent Composieux 1.3k Jan 4, 2023
kubetnl tunnels TCP connections from within a Kubernetes cluster to a cluster-external endpoint, e.g. to your local machine. (the perfect complement to kubectl port-forward)

kubetnl kubetnl (kube tunnel) is a command line utility to tunnel TCP connections from within a Kubernetes to a cluster-external endpoint, e.g. to you

null 5 Dec 16, 2022
A Go based deployment tool that allows the users to deploy the web application on the server using SSH information and pem file.

A Go based deployment tool that allows the users to deploy the web application on the server using SSH information and pem file. This application is intend for non tecnhincal users they can just open the GUI and given the server details just deploy.

Jobin Jose 1 Oct 16, 2021
Integrated ssh-agent for windows. (pageant compatible. openSSH ssh-agent etc ..)

OmniSSHAgent About The chaotic windows ssh-agent has been integrated into one program. Chaos Map of SSH-Agent on Windows There are several different c

YAMASAKI Masahide 51 Dec 19, 2022
webhook forward, such as: synology

Webhook-Forward Usage docker pull starudream/webhook-forward docker run -d starudream/webhook-forward Env ADDR=127.0.0.1:9988 DEBUG=true PROXY=http:/

sheng.wang 0 Jun 10, 2022
Open Service Mesh (OSM) is a lightweight, extensible, cloud native service mesh that allows users to uniformly manage, secure, and get out-of-the-box observability features for highly dynamic microservice environments.

Open Service Mesh (OSM) Open Service Mesh (OSM) is a lightweight, extensible, Cloud Native service mesh that allows users to uniformly manage, secure,

Open Service Mesh 2.5k Jan 2, 2023
Open URL in your local web browser from the SSH-connected remote environment.

opener Open URL in your local web browser from the SSH-connected remote environment. How does opener work? opener is a daemon process that runs locall

Kazuki Suda 58 Oct 20, 2022
Tool (in Go!) to compare and diff container and host environments. Dinosaur fun!

Compenv compare environments between containers, and host ??️ This is a simple tool to compare environments. This means the environment on your host v

Vanessasaurus 1 Sep 24, 2022
Go WhatsApp Multi-Device Implementation in REST API with Multi-Session/Account Support

Go WhatsApp Multi-Device Implementation in REST API This repository contains example of implementation go.mau.fi/whatsmeow package with Multi-Session/

Dimas Restu H 62 Dec 3, 2022
VaultOperator provides a CRD to interact securely and indirectly with secrets stored in Hashicorp Vault.

vault-operator The vault-operator provides several CRDs to interact securely and indirectly with secrets. Details Currently only stage 1 is implemente

finleap connect 3 Mar 12, 2022
azqlite is a lightweight wrapper around Azure's SDK to interact with the Azure Storage Queue service in a simpler and more idiomatic way.

azqlite azqlite is a lightweight wrapper around github.com/Azure/azure-storage-queue-go to interact with the Azure Storage Queue service in a simpler

Jose Garcia 1 Mar 12, 2022
Kubernetes operator providing CRDs to interact with NETCONF servers.

NETCONF operator This operator is meant to provide support for: RFC6241 Network Configuration Protocol (NETCONF) RFC6242 Using the NETCONF Protocol ov

Alexis de Talhouët 0 Nov 17, 2021
A simple operator to interact with a Postgres database.

Built following this blog. Kubebuilder commands use to set up the project mkdir second-operator cd second-operator kubebuilder init --domain arshsharm

Arsh Sharma 0 Nov 27, 2021
Our library to interact with shopware6.

gosw6 Here you can find our library for shopware 6. We develop the API endpoints according to our demand and need. You are welcome to help us to furth

J&J Ideenschmiede GmbH 2 Sep 28, 2022
⚙️ Operating Account Operators (OAO) is a Golang tool to interact with the LDAP protocol to manage account groups, roles, ACLs/ACEs, etc...

⚙️ OAO (Operating Account Operators) ⚙️ Operating Account Operators (OAO) is a Golang tool to interact with the LDAP protocol to manage account groups

Daniel 7 May 11, 2023
Solana Token Registry - a package that allows application to query for list of tokens

Please note: This repository is being rebuilt to accept the new volume of token additions and modifications. PR merges will be delayed. @solana/spl-to

Square and Compass 0 Jan 16, 2022
Emojivoto - A microservice application that allows users to vote for their favorite emoji

Emoji.voto A microservice application that allows users to vote for their favori

Kriil 0 Feb 16, 2022