A very simple ssh server connector to run commands remote.
jdk 21
or higher
# clone project
git clone https://github.com/inpercima/server-connector.git
cd server-connector
Create environment files for devMode
and prodMode
.
cp src/main/resources/application.yml src/main/resources/application-dev.yml
cp src/main/resources/application.yml src/main/resources/application-prod.yml
Note: These files will not be under version control but listed in .gitignore.
# short
./mvnw
# long
./mvnw spring-boot:run -Pdev
# short
./mvnw -Pprod
# long
./mvnw spring-boot:run -Pprod
# package
./mvnw clean package
# package without tests
./mvnw clean package -DskipTests
# place the `application-prod.yml` aside the server-connector-1.0.0-SNAPSHOT.jar and run the jar
cp src/main/resources/application-prod.yml target/application-prod.yml
cd target
java -jar server-connector-1.0.0-SNAPSHOT.jar --spring.profiles.active=prod
All options can be overridden in application-*.yml with prefix app.
.
For example, the port is 22 by default, so it does not need to be overridden.
The host to be connected.
- default:
host
- type:
String
The password for the connection. Attention: The password is in plaintext.
- default:
password
- type:
String
The port for the connection.
- default:
22
- type:
Integer
The user for the connection.
- default:
user
- type:
String
The commands to be send and executed on the server. This is a list of commands with minimum one command.
- default:
ls
- type:
String
Example:
app:
commands:
- cd /home
- ls