]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Feat: adds login command 0.1.0
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 17 May 2024 13:48:32 +0000 (10:48 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 17 May 2024 13:48:32 +0000 (10:48 -0300)
kvmx
kvmxfile

diff --git a/kvmx b/kvmx
index ddd949857b97d9c027c82ffdbbc1dfb3b811f33a..4f0ff6e71e831588b72b69a8dfb2c223a1148927 100755 (executable)
--- 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
index 975aa78a9f8e82ca2d2f6f98cf5676d594b98954..191b1608ab79ad2805fd5a94b4f3bddc8535e0ac 100644 (file)
--- 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"