aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-05-17 10:48:32 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-05-17 10:48:32 -0300
commit3cce6a2ec3ba86f8cd2e760dfae29769daf736fe (patch)
tree1d631de467008b782d09f9077994f95990e25688
parent1d34d2f97c3924f30eb222472473a73abeb0a6da (diff)
downloadkvmx-3cce6a2ec3ba86f8cd2e760dfae29769daf736fe.tar.gz
kvmx-3cce6a2ec3ba86f8cd2e760dfae29769daf736fe.tar.bz2
Feat: adds login command0.1.0
-rwxr-xr-xkvmx15
-rw-r--r--kvmxfile6
2 files changed, 21 insertions, 0 deletions
diff --git a/kvmx b/kvmx
index ddd9498..4f0ff6e 100755
--- a/kvmx
+++ b/kvmx
@@ -881,6 +881,21 @@ function kvmx_ssh {
$ssh_env $SSH_COMMAND -p $SSH 127.0.0.1 $*
}
+# Enhanced SSH login into the guest
+function kvmx_login {
+ # This allows the usage of a custom login command
+ #
+ # It's not implemented directly in kvmx_ssh because it conflicts with use
+ # cases where SSH commands are read from stdin and not from positional
+ # arguments, like `echo something | kvmx_ssh`.
+ if [ -z "$1" ] && [ ! -z "$ssh_login_command" ]; then
+ # This needs the -t option to request a pseudo-terminal
+ kvmx_ssh -t $ssh_login_command
+ else
+ kvmx_ssh $*
+ fi
+}
+
# Get guest SSH key fingerprints
function kvmx_ssh_finger {
if ls $DATADIR/ssh/*.pub.* &> /dev/null; then
diff --git a/kvmxfile b/kvmxfile
index 975aa78..191b160 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -86,6 +86,12 @@ shared_folder_mountpoint="/home/$user/code/$VM"
#startup_rsync_to_guest="data:data:/var/data,code:$HOME/code:/home/user/code"
#poweroff_rsync_from_guest="data:/var/data:data,code:/home/user/code:$HOME/code"
+# SSH login command when using `kvmx login`
+# Login command when SSHing to the guest when no command is specified.
+# Yout might need to invoke a login shell so your environment is populated etc.
+#ssh_login_comman="tmux"
+#ssh_login_command="bash --login -c 'shell local myprofile'"
+
# Graphics
# See https://wiki.archlinux.org/index.php/QEMU#Graphics
#graphics="-vga std -nographic -vnc :$GUEST_DISPLAY"