From 3cce6a2ec3ba86f8cd2e760dfae29769daf736fe Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 17 May 2024 10:48:32 -0300 Subject: Feat: adds login command --- kvmx | 15 +++++++++++++++ kvmxfile | 6 ++++++ 2 files changed, 21 insertions(+) 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" -- cgit v1.2.3