Remote Manager
Setup
0. Preparation
You need to install docker and optionally docker compose in order to use this tool.
1. Clone project
git clone git@github.com:lazy-ants/remote-manager.git
cd remote-manager
2. Initial setup
make init
or in case of updating in the future:
make update
3. Add server connection to the config
Open config.json with the editor of your choice and add server connections. It means "user@domain:port", however the port is optional.
4. Running configuration
With docker:
docker run -it --rm -v "$PWD":/usr/src/remote-manager -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub -v ~/.ssh/id_rsa:/root/.ssh/known_hosts remote-manager ./run app:validate-config
With docker-compose:
docker-compose run remote-manager ./run app:validate-config
Result
5. Run you first command to see e.g. the server uptime
To test this setup run
With docker
docker run -it --rm -v "$PWD":/usr/src/remote-manager -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub -v ~/.ssh/id_rsa:/root/.ssh/known_hosts remote-manager ./run app:uptime
with docker composer:
docker-compose run remote-manager ./run app:uptime
Available commands
app:docker-compose-version
Get docket compose version
app:docker-prune
Prune old docker data
app:docker-ps
Show docker process status
app:kernel
Get server kernels
app:ls
Run ls command on all servers
Examples
app:ls
default value, with -lha argumetns list the current directoryapp:ls './ -la'
list the current directoryapp:ls '../ -la'
list the up directoryapp:ls '/ -la'
list the root directory
app:os
Get server OS
app:check-reboot
Checks whether a reboot is required Use option "--reboot" or "-r" to immediately reboot if required
app:system-info
- note: [sudo required]
- Get system information
app:ufw
- note: [sudo required]
- Get UFW status
app:upgrade
- note: [sudo required]
- Upgrade server packages
app:uptime
Get server uptime
app:validate-config
Validate server instances config
FAQ
Using tags
You can add to each server instance in the config.json tags, e.g.
{
"instances": [
{
"name": "example.com",
"connection-string": "user@example1.com",
"tags": "staging,client1"
},
{
"name": "example.org",
"connection-string": "otheruser@example2.org",
"tags": "live,client1"
},
{
"name": "example.net",
"connection-string": "someotheruser@example3.net",
"tags": "staging,client3"
}
]
}
and call every command with tags of servers you need:
app:uptime -t client1
app:uptime -t client2,staging
Login into console
If you want to login into the docker container:
reman-cli bash
Running command needed the sudo password
Prepare servers you want to manage:
First of all, you need a possibility to provide the sudo password in a secure way as an environment variable to your server (for sure in case you need the possibility of running commands with sudo). Therefore, On each server you want to manage edit
sudo nano /etc/ssh/sshd_config
add at the end of the config:
AcceptEnv PASSWORD
reload the sshd server e.g.
sudo service sshd reload
After that you either need to provide the sudo password in the .env.local file in case the most of your servers use the same sudo password or you can add in the config.json file in each configuration sectiona using the key "sudo-ppassword".
Adding aliases
In case you want to simplify using this tool you may want to add aliases.
In case you have OS specific options like "UseKeychain yes" on MacOS in your .ssh/config:
alias reman-cli='docker run -it --rm -v "$PWD":/usr/src/remote-manager -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub -v ~/.ssh/id_rsa:/root/.ssh/known_hosts remote-manager'
alias reman-console='docker run -it --rm -v "$PWD":/usr/src/remote-manager -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub -v ~/.ssh/id_rsa:/root/.ssh/known_hosts remote-manager ./run'
Otherwise you can simple map the whole .ssh directory:
alias reman-cli='docker run -it --rm -v "$PWD":/usr/src/remote-manager -v ~/.ssh:/root/.ssh remote-manager'
alias reman-console='docker run -it --rm -v "$PWD":/usr/src/remote-manager -v ~/.ssh:/root/.ssh remote-manager ./run'
Or if you prefer docker-compose:
alias reman-cli='docker-compose run remote-manager bash'
alias reman-console='docker-compose run remote-manager ./run'
Contributing
Remote Manager is an open source project. If you find bugs or have proposal please create issue or Pull Request
License
Copyright 2021 Lazy Ants
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.