Skip to content

cotta-dev/retri

Repository files navigation

Retri

English | 日本語

CI Release License: MIT

SSH Log Collector & Command Executor

The name Retri comes from Retriever — the dog breed famous for fetching things back. Just like a retriever, this tool goes out to your servers and brings back logs.

It was born from a desire to replicate the TeraTerm log + macro workflow in WSL (Windows Subsystem for Linux): define your commands in a config file, and Retri handles SSH connections, execution, and log saving automatically.

Key Features

  • Local Session Recording: Run without any arguments to record your current shell session to a log file — just like TeraTerm's log function.
  • SSH Session Recording: Pass a hostname as an argument to SSH into a remote host and record the entire session automatically.
  • Automated Command Execution: Execute commands across multiple hosts and save timestamped logs — equivalent to a TeraTerm macro.
  • Agentless: Works with standard SSH. No software required on remote hosts.
  • Dependency Free: Single binary (statically linked). Download and run.
  • Network Device Support: Handles interactive PTY sessions for Cisco IOS, Arista EOS, Juniper, Huawei, etc. Passwords are never written to logs.
  • Parallel Execution: Run commands on multiple servers concurrently.
  • SSH Config Aware: Fully supports ~/.ssh/config (aliases, proxy jumps, identity files).

Installation

Ubuntu/Debian (recommended)

curl -fsSL $(curl -fsSL https://api.github.com/repos/cotta-dev/retri/releases/latest \
  | grep browser_download_url | grep "$(dpkg --print-architecture).deb" | cut -d'"' -f4) \
  -o /tmp/retri.deb && sudo apt-get install -y /tmp/retri.deb

Or download the .deb manually from the Releases page:

cp retri_VERSION_amd64.deb /tmp/
sudo apt-get install -y /tmp/retri_VERSION_amd64.deb

Build from Source

git clone https://github.com/cotta-dev/retri.git
cd retri
CGO_ENABLED=0 go build -o retri -ldflags="-s -w" .

Install with Go

CGO_ENABLED=0 go install github.com/cotta-dev/retri@latest

Usage

Record a Local Work Session (no arguments)

Running retri without any arguments starts recording your current shell session to a log file.

retri
# → starts logging to ~/retri-logs/hostname_YYYYMMDD_HHmmss.log
# → type 'exit' or press Ctrl-D to stop recording

SSH + Record Session (hostname as argument)

Pass a hostname to SSH into the remote host and record the entire interactive session.

retri myserver
# → SSHes to myserver and records the session to ~/retri-logs/myserver_YYYYMMDD_HHmmss.log
# → type 'exit' to disconnect and stop recording

Automate Commands and Collect Logs

Run a command on a single host (using ~/.ssh/config alias):

retri --host myserver --command "df -h"

Run commands on a group of servers defined in config:

retri --group web_servers

Command Line Options

See docs/cli-options.md for the full option reference.

Configuration

On the first run, retri automatically creates a default configuration file at ~/.config/retri/config.yaml.

Example config.yaml

See docs/config-reference.yaml for the complete parameter reference of each section.

Environment Variables & Security

Avoid hardcoding passwords in the config file. Retri supports ${VAR} expansion:

export COMMON_SSH_PASSWORD="my_secret_password"
defaults:
  password: "${COMMON_SSH_PASSWORD}"

Fallback environment variables (lowest priority):

Variable Description
RETRI_SSH_PASSWORD Default SSH password if no other config is found.
RETRI_SSH_SECRET Default sudo secret if no other config is found.

Output Format

Logs are saved to ~/retri-logs by default.

File: myserver_20260403_010842.log

============================================================
 TARGET HOST : myserver
 DEVICE TYPE : linux
 START TIME  : 2026-04-03 01:08:42
============================================================
[2026-04-03 01:08:43.550] 
[2026-04-03 01:08:43.551] ----------------------------------------
[2026-04-03 01:08:43.551] [EXEC] uptime
[2026-04-03 01:08:43.551] ----------------------------------------
[2026-04-03 01:08:43.594]  01:08:43 up 77 days,  9:44,  0 user,  load average: 0.10, 0.56, 0.40
[2026-04-03 01:08:43.595] 
[2026-04-03 01:08:43.595] ----------------------------------------
[2026-04-03 01:08:43.595] [EXEC] sudo whoami
[2026-04-03 01:08:43.595] ----------------------------------------
[2026-04-03 01:08:43.596] root

============================================================
 LOG END     : 2026-04-03 01:08:43
============================================================

License

Distributed under the MIT License. See LICENSE for more information.

About

Automate SSH log collection across servers and network devices — a lightweight Tera Term alternative

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages