SVPS, initially designed to simplify tasks for non-Unix users, works as an ORM for Ubuntu Servers.
It supports command automation, files and directories upload via SFTP, automatic installations and configurations, domain forwarding, local text files and template strings into escaped quoted strings for dynamic remote file creation, among other features.
All this, using just a single one connection π§π»β¨
npm i svps
import { SVPS } from 'svps';
/** Prepare the connection */
const svps = new SVPS({
access: {
host: '127.0.0.1',
username: 'root',
password: 'root',
},
});
/** For AWS */
const svps = new SVPS({
access: {
host: '***.amazonaws.com',
username: 'ubuntu',
privateKey: fs.readFileSync('./your_rsa.pem'),
},
});
/** Available methods
* svps.mount
* svps.commands
* svps.createVirtualHosts
* svps.upload
* svps.end
*
* See about each below π΅π»
*/
await svps.mount({
php: true || { version: 8.2, composer: true },
node: true || { version: 18, packages: ['yarn'] },
apache: true,
docker: true,
// ...
/**
* ... Users, Desktop (RDP), Firewall, etc.
*
* See all available automatic installations below ππ»
*/
});
- Repair common possible conflicts and vulnerabilities on Ubuntu
- Run common
apt
commands - Set the most common Firewall (
ufw
) settings- This will activate the SSH port according to the entered port or
22
by default - The Firewall has different behaviors when combined with Desktop and MySQL
- This will activate the SSH port according to the entered port or
- Create users and groups
- SFTP by enabling it for any user
- FTP (
vsftpd
) by enabling it for any user - RSA Certificate
- Docker and Docker Compose
- PHP
- Node.js
- MySQL
- Crontab
- Remote Desktop Protocol (RDP)
- Restart the Server
See some practical examples.
- The entire remote process is displayed on console in real time
- Find all the commands behind SVPS in src/lib/tasks/steps
- This may take a long time depending on your VPS specifications
Create your own commands and combine with other SVPS features.
const commands = ['echo "π"'];
await svps.commands(commands);
- You can use the
escapeQuotes
method to create multi-line escaped quoted strings. See an example here.
Transfer your local files and directories and set permissions for each upload.
await svps.upload([
{
local: './my-app-dist',
remote: '/workspace',
permissions: {
user: 'my-user',
},
},
]);
- It uses SFTP to send the content to remote server
Download your remote files.
await svps.download([
{
remote: '/workspace/backup.zip',
local: './my-local-path/backup.zip',
},
]);
- It uses SFTP to get the content from remote server
await svps.createVirtualHosts([
// Basic or Advanced Virtual Hosts
]);
/**
* This will create a log with the processed domains to ensure that only new domains are processed.
* If you delete this log, the domains will be understood as new and will be overwritten.
*/
You can automatically create Node.js (LTS) and PHP (8.2) services and work on them in /var/containers/domains
/your_domain
.
Also, it allows to use an exclusive MySQL database for each domain.
await svps.createVirtualHosts([
{
domain: 'site.com',
port: 5000,
www: true /** creates an alias for "www.site.com" */,
server: {
language: 'node' | 'php',
mysql: {
database: 'db-name',
password: 'db-pass',
expose: 5001 /** expose port 5001 locally */,
isPublic: true /** expose port 5001 outside the VPS */,
},
},
},
]);
- For PHP, you can flag the
server
optionbuildFromScratch
astrue
to create the Virtual Host image from scratch, otherwise it will pull the images from my Docker Hub ππ»ββοΈ
To create flexible Basic Virtual Hosts, SVPS uses Docker containers and Apache2 to proxy their ports to your domains.
Apache2, Docker and Docker Compose required.
See some practical examples here.
By using the Virtual Hosts solely to proxy your services, you can create services in any language you choose, by simply defining the port your service is on.
await svps.createVirtualHosts([
{
domain: 'site.com',
port: 5000,
www: true /** creates an alias for "www.site.com" */,
},
]);
// It will proxy your service at port 5000 to "site.com" and "www.site.com"
Apache2 required.
await svps.mount({
desktop: true,
});
/** That's it π€Ήπ»ββοΈ */
- It will install Xubuntu Desktop and RDP Remote in port
3389
- The desktop installation can take longer and take up more disk space (about 1GB to 3GB)
- If you are using a container, remember to expose the port
3389
- To access, use your credentials in a Remote Desktop Software
See a practical example using a Docker container.
-
Create the container:
docker run -d --privileged -p 22:22 --restart always wellwelwel/vps:latest
- Add
-p 3389:3389
if you want to test it using Remote Desktop Protocol - See more in hub.docker.com/r/wellwelwel/vps
- Add
-
Then, set the default access:
const svps = new SVPS({ access: { host: '127.0.0.1', username: 'root', password: 'root', port: 22, }, });
await svps.end();
- This package is designed for pre-built VPS, KVM and Ubuntu Server
>=18.04
- The SSH user needs to be the root or a super user
- Avoid running this tool on a server that is already in production, unless you know what you're doing π§π»
- Node.js
>=18
is not compatible with Ubuntu18.04
- I think it's not possible to use a Docker container with RDP inside a VPS without RDP
- Any help on this is welcome π
I'm continuously working to improve SVPS. If you've got something interesting to share, feel free to submit a Pull Request. If you notice something wrong, I'd appreciate if you'd open an Issue.
Please check the CONTRIBUTING.md for instructions π