lucent-sea / Remotely
- четверг, 2 сентября 2021 г. в 00:38:12
A remote control and remote scripting solution, built with .NET 5, Blazor, SignalR Core, and WebRTC.
A remote control and remote scripting solution, built with .NET 5, Blazor, SignalR Core, and WebRTC.
Repo is "On Pause"
My family and I have recently moved into a new house. Until we've settled in and adjusted to the changes, the repo will be archived. This is for my own peace of mind, as it's rather stressful to see requests/issues come in when I don't have time to address them.
Once I'm ready to resume the project, the archival will be removed.
If this project has benefited you in some way, or if you just want to show appreciation, please consider donating to a charity.
Suggested Charities: https://www.givewell.org/charities/top-charities
You can also sponsor the project as a way of saying "thank you". But if you have to pick between the two, please choose a charity. Your money will have a much greater impact on their lives than it would mine.
Public Server: https://remotely.lucency.co
Website: https://remotely-info.lucency.co
Subreddit: https://www.reddit.com/r/remotely_app/
Docker: https://hub.docker.com/r/translucency/remotely
Video Tutorials: https://remotely-info.lucency.co/Tutorials
Hosting a Remotely server requires running an ASP.NET Core web app behind IIS (Windows), Nginx (Ubuntu), or Caddy Server (any OS). It's expected that the person deploying and maintaining the server is familiar with this process. Since this is a hobby project that I develop in between working full time and raising a family, there simply isn't time available to provide support in this capacity.
GitHub Actions allows you to build and deploy Remotely for free from their cloud servers. Since the Windows agent can only be built on Windows, and the Mac agent can only be built on Mac, using a build platform like GitHub Actions or Azure Pipelines is the only reasonable way to build the whole project. The definitions for the build processes are located in /.github/workflows/
folder.
I've created a cross-platform command line tool that can leverage the GitHub Actions REST API to build the project and install it on your private server. This process will also embed your server's URL into the desktop clients, so that they won't need to prompt the end user to enter it.
Branding will not work for the agent installer or quick support clients (in most cases) unless the server URL is embedded this way. There is no way for the self-contained EXE to know what server to contact unless it's been compiled into it.
However, you can also choose to install the pre-built packages that do not have any server URLs embedded. These don't require you to fork the repository on GitHub.
ping remotely.lucency.co
and see the IP address to which it resolves.Remotely_Server_Installer[.exe]
CLI tool for the latest release on the Releases page.
--help
argument to see all the command line arguments.
{your-username}
with your GitHub username. This example assumes you've added your SSH key to your GitHub account.
git clone git@github.com:{your-username}/remotely
cd ./remotely
git remote add upstream https://github.com/lucent-sea/remotely
git pull upstream master
git push origin master
repo
scope.repository
line in Build.yml
(in your repo). There's a comment in the file that points out the line.appsettings.json
file and name it appsettings.Production.json
.
Register
button on the main page.
Register
button will disappear.MaxOrganizationCount
or set it to -1 (see Configuration section).rsync
/robocopy
the output files to the server directory.dotnet publish /p:PublishProfile=MyProfile
)appsettings.Production.json
. These files should never exist in the publish output.There are countless ways to host an ASP.NET Core app, and I can't document or automate all of them. For hosting scenarios aside from the above two, please refer to Microsoft's documentation.
The following steps will configure your Windows 10 machine for building the Remotely server and clients.
git clone https://github.com/lucent-sea/remotely
The first account created will be an admin for both the server and the organization that's created for the account.
An organization admin has access to the Organization page and server log entries specific to his/her organization. A server admin has access to the Server Config page and can see server log entries that don't belong to an organization.
Within the Account section, there is a tab for branding, which will apply to the quick support clients and Windows installer.
However, the clients will need to have been built from source with the server URL hard-coded in the apps for them to be able to retrieve the branding info.
The following settings are available in appsettings.json, under the ApplicationOptions section.
When deployed to production, the application will use the appsettings.Production.json
file, if it's present. To retain your settings between upgrades, copy your appsettings.json
file to appsettings.Production.json
on your production server, then make your configuration changes.
Likewise, appsettings.Development.json
can be used while developing in Visual Studio to override the other.
Whenever there's a reference to appsettings.json
in this document, it refers to whichever file is currently being used.
For more information on configuring ASP.NET Core, see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/.
By default, Remotely uses a SQLite database. When first run, it creates a file as specified for the SQLite connection string in appsettings.json.
You can change database by changing DBProvider
in ApplicationOptions
to SQLServer
or PostgreSQL
. Be sure to set the connection string for the new database provider in the server's appsettings.Production.json
.
Ideally, you'd be doing remote control from an actual computer or laptop. However, I've tried to make the remote control at least somewhat usable from a mobile device. Here are the controls:
There's a page at /GetSupport
where end users can request support. When the form is submitted, an alert appears on the main page, above the grid.
A shortcut to this page is placed in the \Program Files\Remotely\
folder. You can copy it anywhere you like. You can also have it copied to the desktop automatically by using the -supportshortcut
switch on the installer.
There are a few shortcut keys available when using the console.
You can change the local port that the Remotely .NET server listens on by adding the below to appsettings.Production.json
:
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:{port-number}"
}
}
}
Alternatively, you can use a command-line argument for the Remotely_Server
process or set an environment variable.
--urls http://localhost:{port-number}
ASPNETCORE_URLS=http://localhost:{port-number}
Remotely has a basic API, which can be browsed at https://remotely.lucency.co/swagger (or your own server instance). Most endpoints require authentication via an API access token, which can be created by going to Account - API Access.
When accessing the API from the browser on another website, you'll need to set up CORS in appsettings by adding the website origin URL to the TrustedCorsOrigins array. If you're not familiar with how CORS works, I recommend reading up on it before proceeding. For example, if I wanted to create a login form on https://lucency.co that logged into the Remotely API, I'd need to add "https://lucency.co" to the TrustedCorsOrigins.
The API key and secret must be added to the request's Authorization header in the following format: [ApiKey]:[ApiSecret]
Below is an example API request:
POST https://localhost:5001/API/Scripting/ExecuteCommand/PSCore/f2b0a595-5ea8-471b-975f-12e70e0f3497 HTTP/1.1
Content-Type: application/json
Authorization: 31fb288d-af97-4ce1-ae7b-ceebb98281ac:HLkrKaZGExYvozSPvcACZw9awKkhHnNK
User-Agent: PostmanRuntime/7.22.0
Accept: */*
Cache-Control: no-cache
Host: localhost:5001
Accept-Encoding: gzip, deflate, br
Content-Length: 12
Connection: close
Get-Location
Below are examples of using the cookie-based login API (JavaScript):
// Log in with one request, then launch remote control with another.
fetch("https://localhost:5001/api/Login/", {
method: "post",
credentials: "include",
mode: "cors",
body: '{"Email":"email@example.com", "Password":"P@ssword1"}',
headers: {
"Content-Type": "application/json",
}
}).then(response=>{
if (response.ok) {
fetch("https://localhost:44351/api/RemoteControl/b68c24b0-2c67-4524-ad28-dadea7a576a4", {
method: "get",
credentials: "include",
mode: "cors"
}).then(response=>{
if (response.ok) {
response.text().then(url=>{
window.open(url);
})
}
})
}
})
// Log in and launch remote control in the same request.
fetch("https://localhost:5001/api/RemoteControl/", {
method: "post",
credentials: "include",
mode: "cors",
body: '{"Email":"email@example.com", "Password":"P@ssword1", "DeviceID":"b68c24b0-2c67-4524-ad28-dadea7a576a4"}',
headers: {
"Content-Type": "application/json",
}
}).then(response=>{
if (response.ok) {
response.text().then(url=>{
window.open(url);
})
}
})
The Alerts API gives you the ability to add monitoring and alerting functionality to your device endpoints. This feature is intended to add basic RMM-type functionality without diverging too far from Remotely's primary purpose.
Alerts can be set up to show a notification on the Remotely website, send an email, and/or perform a separate API request.
To use Alerts, you'd first need to make an API token (or multiple tokens) for your devices to use. Then create a scheduled task or some other recurring script to do the work. Below is an example of how to use PowerShell to create a Scheduled Job that checks the disk space on a daily schedule.
$Trigger = New-JobTrigger -Daily -At "5 AM"
$Option = New-ScheduledJobOption -RequireNetwork
Register-ScheduledJob -ScriptBlock {
$OsDrive = Get-PSDrive -Name C
$FreeSpace = $OsDrive.Free / ($OsDrive.Used + $OsDrive.Free)
if ($FreeSpace -lt .1) {
Invoke-WebRequest -Uri "https://localhost:5001/api/Alerts/Create/" -Method Post -Headers @{
Authorization="3e9d8273-1dc1-4303-bd50-7a133e36b9b7:S+82XKZdvg278pSFHWtUklqHENuO5IhH"
} -Body @"
{
"AlertDeviceID": "f2b0a595-5ea8-471b-975f-12e70e0f3497",
"AlertMessage": "Low hard drive space. Free Space: $([Math]::Round($FreeSpace * 100))%",
"ApiRequestBody": null,
"ApiRequestHeaders": null,
"ApiRequestMethod": null,
"ApiRequestUrl": null,
"EmailBody": "Low hard drive space for device Maker.",
"EmailSubject": "Hard Drive Space Alert",
"EmailTo": "translucency_software@outlook.com",
"ShouldAlert": true,
"ShouldEmail": true,
"ShouldSendApiRequest": false
}
"@ -ContentType "application/json"
}
} -Name "Check OS Drive Space" -Trigger $Trigger -ScheduledJobOption $Option