xxh

xxh

便携式 SSH 跨主机 Shell 环境工具

xxh 允许在远程 Linux 主机上通过 SSH 使用自定义 shell 环境,无需 root 权限或系统安装。支持 Xonsh、Fish、Zsh、OSQuery 等多种 shell,提供便携性、隔离性和可定制性。用户可携带自定义配置、插件和工具,实现个性化的远程终端体验。适用于需要在多台主机间保持一致 shell 环境的开发者和系统管理员。

xxhSSHshell跨平台便携性Github开源项目
<p align="center">You stuffed your command shell with aliases, tools, and colors but you lose it all when using ssh. The mission of xxh is to bring your favorite shell wherever you go through ssh without root access or system installations. Xonsh shell, fish, zsh, osquery and so on.</p> <p align="center"> If you like the idea of xxh click ⭐ on the repo and <a href="https://twitter.com/intent/tweet?text=Bring%20your%20favorite%20shell%20wherever%20you%20go%20through%20the%20ssh.&url=https://github.com/xxh/xxh" target="_blank">tweet</a>. </p>

<a href='https://github.com/xxh/xxh#installation-methods'><img alt='[xxh demo]' src='https://raw.githubusercontent.com/xxh/static/master/xxh-demo2.gif'></a>

<table border="0" width="100%"> <col style="width:33%"> <col style="width:33%"> <col style="width:33%"> <tbody> <tr style="border: 0px !important;"> <td valign="top" style="border: 0px !important;"><b>Portable</b>. Preparing portable shells and plugins occurs locally, and then xxh uploads the result to the host. No installations or root access on the host required. Security and host environment are a prime focus.</td> <td valign="top" style="border: 0px !important;"><b>Hermetic</b>. Deleting the <code>~/.xxh</code> directory from the remote host will make the remote environment function as if xxh was never there. By default your home is the <code>.xxh</code> directory and you can <a href="https://github.com/xxh/xxh/wiki#how-to-set-homeuser-as-home-on-host">choose the hermetic level of your xxh session</a>.</td> <td valign="top" style="border: 0px !important;"><b>Careful</b>. No blindfolded copying config files from local to remote host. Following privacy and repeatability practices, the best way is to fork the xxh plugin or shell example and pack your configs into it. </td> </tr> <tr style="border: 0px !important;"> <td valign="top" style="border: 0px !important;"><b>Be open and fork-ready</b>. Every xxh repo could be forked, customized, and reused without waiting for a package management system, xxh release, or any third party packages. Five shells are currently supported and more could be added by the community.</td> <td valign="top" style="border: 0px !important;"><b>Do more</b>. The xxh packages are not only about shells. Any type of tool or code could be behind an entrypoint. If you want to run <a href="https://github.com/browsh-org/browsh">browsh</a> or <a href="https://github.com/juftin/browsr">browsr</a> on the remote host, just put its portable version as an entrypoint in the xxh-shell.</td> <td valign="top" style="border: 0px !important;"><b>Chameleon</b>. Switching shells is as easy as possible and you don't have to be locked in to one shell. Choose your current shell based on the task you want to solve: <code>xxh anyhost +s xonsh</code> for a Python environment, osquery for simple querying, fish for modern features or time-tested zsh and bash for speed. </td> </tr> </tbody> </table>

Installation methods

PyPi 3

pip install xxh-xxh # OR from repo: pip install git+https://github.com/xxh/xxh

pipx - good alternative to brew and pip, read comparison

pipx install xxh-xxh

xonsh shell

xpip install xxh-xxh

Conda-forge feedstock

conda config --add channels conda-forge conda install xxh-xxh

Homebrew

brew install xxh

Macports

sudo port install xxh

Linux portable binary

mkdir ~/xxh && cd ~/xxh wget https://github.com/xxh/xxh/releases/download/0.8.12/xxh-portable-musl-alpine-Linux-x86_64.tar.gz tar -xzf xxh-portable-musl-alpine-Linux-x86_64.tar.gz ./xxh

Linux AppImage

mkdir ~/xxh && cd ~/xxh wget -O xxh https://github.com/xxh/xxh/releases/download/0.8.12/xxh-x86_64.AppImage chmod +x xxh && ./xxh

To run AppImage on Alpine Linux install alpine-pkg-glibc with localedef.

Shells

Currently supported OS for the target host is Linux on x86_64.

xxh-shellstatusxxh-pluginsseamlessdemo
xonshstableautojump, [+]xxh.xsh<a href="https://asciinema.org/a/osSEzqnmH9pMYEZibNe2K7ZL7" target="_blank">demo</a>
zshstableohmyzsh, p10k, [+]xxh.zsh<a href="https://asciinema.org/a/rCiT9hXQ5IdwqOwg6rifyFZzb" target="_blank">demo</a>
fishstableohmyfish, fisher, userconfig, [+]todo
bashstableohmybash, [+]xxh.bash<a href="https://asciinema.org/a/314508" target="_blank">demo</a>
osquerybeta
fish-appimagealpha
elvishalpha

Search xxh shell on Github or Bitbucket or create your shell entrypoint to use another portable shell.

Prerun plugins

Prerun plugins allow you to bring any portable tools, dotfiles, or aliases to your xxh session before running the shell.

Pinned plugins: core (xxh-sudo, xxh-screen, xxh-tmux), dotfiles, docker, python, xxh, vim, zoxide, starship. There is cookiecutter template to create a prerun plugin.

Usage

Use xxh instead of ssh when connecting to Linux hosts without changing ssh arguments:

xxh <host from ~/.ssh/config>
xxh [ssh arguments] [user@]host[:port] [xxh arguments]
xxh local [xxh arguments]

Common examples (use xxh --help to get info about arguments):

xxh anyhost # Connect to the host xxh -i id_rsa -p 2222 anyhost # Using ssh arguments: port and key xxh user@host +c et # Using EternalTerminal (https://github.com/MisterTea/EternalTerminal) xxh anyhost +s zsh +i # Set the shell and install it without yes/no question xxh anyhost +s xonsh +hhh "~" # Set /home/user as home directory (read Q&A) xxh anyhost +s bash +I xxh-plugin-bash-vim # Preinstall a plugin xxh anyhost +if +q # Force reinstall xxh on the host in quiet mode xxh anyhost +hh /tmp/xxh +hhr # Upload xxh to /tmp/xxh and remove when disconnecting source xxh.zsh anyhost +I xxh-plugin-zsh-ohmyzsh # Connect in seamless mode with ohmyzsh plugin xxh local +s xonsh # Experimental: build xxh environment inplace and without ssh

For reusing arguments and simplifying xxh usage (like shortening to xxh anyhost), there is a config file.

Why the plus sign for the xxh arguments? The xxh is using the plus sign for xxh arguments to preserve the ability to use the minus sign for the original ssh arguments. This allows just replacing the first two letters in the ssh command to convert it to the xxh command. Also see the discussion.

Installing xxh packages

xxh [+I xxh-package +I ...] [+L] [+RI xxh-package +RI ...] [+R xxh-package +R ...]

Different ways to set the xxh package source:

xxh +I xxh-shell-example # install from https://github.com/xxh xxh +I https://github.com/xxh/xxh-shell-example # short url for github only, for other sources use examples below or add support xxh +I https://github.com/xxh/xxh-shell-example/tree/mybranch # short url for github only, for other sources use examples below or add support xxh +I xxh-shell-example+git+https://github.com/xxh/xxh-shell-example # long url for any git repo xxh +I xxh-shell-example+git+https://github.com/xxh/xxh-shell-example/tree/mybranch # github only branch support xxh +I xxh-shell-example+git+git@github.com:githubuser/xxh-shell-example.git # install from private repository using ssh xxh +I xxh-shell-example+path+/home/user/my-xxh-dev/xxh-shell-example # install from local path

Using xxh inplace without ssh connection

This is experimental magic. Please read the text below twice.

If you have shell access on the host or you're in a docker container and you can't ssh to it then you can download and build a hermetic xxh environment inplace. The xxh local command works exactly like xxh remote_host and creates a hermetic environment in ~/.xxh by default.

At this time we don't have portable build tools like git, wget, curl, tar and others which could be required by some xxh package build scripts. When running xxh local it is expected that the tools are present on the host.

To run xxh inplace on Linux x86_64 just copy and paste these bash commands:

XH=~/.xxh \ && XD=https://github.com/xxh/xxh-portable/raw/master/result/xxh-portable-musl-alpine-Linux-x86_64.tar.gz \ && mkdir -p $XH && cd $XH \ && ( [[ -x $(command -v curl) ]] && curl -L $XD || wget -O- $XD ) | tar zxf - xxh \ && echo 'Usage: ./xxh local [+s xonsh/zsh/fish/osquery/bash]'

Next time you're on the host just run ~/.xxh/xxh local and you will enter your xxh environment.

Examples of use cases

Python with pip everywhere without installation

Way 1. Using xonsh

xxh anyhost +s xonsh

anyhost> python --version
Python 3.8.2

You'll get python-powered xonsh shell with portable python and pip on the host without any system installations on the host. You can install PyPi packages manually or bring them with you automatically by using xxh-plugin-prerun-dotfiles. Also, don't forget about xxh-plugins like zoxide.

Way 2. Using portable python on any xxh shell

xxh +RI xxh-plugin-prerun-python
xxh anyhost +s zsh

anyhost> python --version
Python 3.8.2
anyhost> pip install pandas

Using xxh-plugin-prerun-python you'll get a portable Python AppImage which can be used on a host without python and with any xxh shell.

Using docker on host without root access

Try xxh-plugin-prerun-docker:

xxh +RI xxh-plugin-prerun-docker
xxh anyhost +if

anyhost> xxh-docker-run
anyhost> docker ps                                                                                                                                                                                                                            
CONTAINER ID        IMAGE               COMMAND
anyhost> docker run --rm hello-world | grep Hello
Hello from Docker!
anyhost> xxh-docker-stop

Bring dotfiles to xxh session

There is the xxh-plugin-prerun-dotfiles plugin which creates config files when you go to the host using xxh. You can fork it and create your cozy settings once and forever.

Seamless Oh My Zsh (demo)

source xxh.zsh anyhost +I xxh-plugin-zsh-ohmyzsh +if +q

This command brings your current Oh My Zsh session theme to the xxh session. If you need more complex settings just fork the xxh-plugin-zsh-ohmyzsh and hack it.

Read host as a table with osquery

$ xxh anyhost +s osquery
osquery> SELECT * FROM users WHERE username='news';
+-----+-----+----------+-------------+-----------------+-------------------+
| uid | gid | username | description | directory       | shell            

编辑推荐精选

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI助手AI工具AI写作工具AI辅助写作蛙蛙写作学术助手办公助手营销助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

聊天机器人AI助手热门AI工具AI对话
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

热门AI工具AI办公办公工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

模型训练热门AI工具内容创作智能问答AI开发讯飞星火大模型多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

下拉加载更多