This file demonstrates using org-babel and tramp together to execute a
source block on a remote host. It was tested with Emacs 27.1 launched
as emacs -Q
(zero custom configuration).
I recommend that you download the raw version of this file, open it in Emacs, and evaluate the blocks yourself. In fact, if you don’t then you will miss the most important parts because they are hidden in the fancy GitHub rendering.
By default org-mode only allows evaluating elisp.
Enable shell as well by evaluating the following: Place your point
anywhere on the block and do C-c C-c
.
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(shell . t)))
Now you can evaluate the following block:
uname -a
To evaluate a block on a remote machine via Tramp, set the :dir
header value appropriately with Tramp syntax. Here, thrillho
is the
hostname of a machine on my local network.
uname -a