Essh is a single binary CLI tool and simply wraps ssh command.
You can use it in the same way as ssh. And it has useful features over ssh.
You can write SSH client configuration (aka: ~/.ssh/config
) in Lua code. So your ssh_config can become more dynamic.
Essh supports hooks that execute commands when it connects a remote server.
Essh provides utilities for managing hosts, that list and classify servers by using tags.
Essh supports per-project configuration. This allows you to change SSH hosts config by changing current working directory.
Task is a script that runs on remote and local servers. You can use it to automate your system administration tasks.
Essh is an open source software that is licensed the MIT License.
Essh configuration is written in Lua.
You can also use DSL syntax that is more human-readable. See below examples:
Configuration:
host "webserver-01" {
HostName = "192.168.56.32",
Port = "22",
User = "kohkimakimoto",
description = "web server-01",
hooks_after_connect = {
"echo -------------------------------------------------",
"echo I am in $(pwd)",
"cat /etc/redhat-release",
"echo ",
"echo This message was displayed by hook functionality.",
"echo -------------------------------------------------",
},
tags = {
"web",
},
}
host "webserver-02" {
HostName = "192.168.56.33",
Port = "22",
User = "kohkimakimoto",
description = "web server-02",
tags = {
"web",
},
}
host "dbserver-01" {
HostName = "192.168.56.34",
Port = "22",
User = "kohkimakimoto",
description = "db server-01",
tags = {
"db",
},
}
Demo:
Configuration:
task "hello" {
description = "say hello",
prefix = true,
backend = "remote",
targets = "web",
script = [=[
echo "hello on $(hostname)"
]=],
}
task "hello-after-confirm" {
description = "say hello after you entering 'y'",
prepare = function()
local question = require "question"
local r = question.ask("Are you OK? [y/N]: ")
if r ~= "y" then
-- return false, the task does not run.
return false
end
end,
prefix = true,
backend = "remote",
targets = "web",
script = [=[
echo "hello on $(hostname)"
]=],
}
Demo:
Essh is provided as a single binary. You can download it and drop it in your $PATH.