diff options
-rwxr-xr-x | kvmx | 50 |
1 files changed, 49 insertions, 1 deletions
@@ -61,7 +61,9 @@ function kvmx_app_base { # Build a SSH command function __kvmx_ssh_command { # See http://blog.djm.net.au/2013/11/chacha20-and-poly1305-in-openssh.html - SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=FATAL -o ProxyCommand=none -o Ciphers=chacha20-poly1305@openssh.com -i $1" + SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=FATAL -o ProxyCommand=none -o Ciphers=chacha20-poly1305@openssh.com -i $1" + SSH_COMMAND="ssh $SSH_OPTS" + SCP_COMMAND="scp $SSH_OPTS" } # Create a guest entry at the global user config folder @@ -570,6 +572,52 @@ function kvmx_rsync { rsync -av -e "$SSH_COMMAND -o Port=$SSH" --rsync-path "sudo rsync" $ORIG/ $SSH_LOGIN@127.0.0.1:$DEST/ } +# Copy files from the guest +function kvmx_scp_from { + if ! kvmx_running; then + echo "$BASENAME: guest $VM is not running" + exit 1 + fi + + ORIG="$3" + DEST="$4" + SSH="`cat $SSHFILE`" + + if [ -z "$DEST" ]; then + exit 1 + fi + + # Fix ~/ path + if echo $ORIG | grep -q -e "^$HOME"; then + ORIG="$(echo $ORIG | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" + fi + + $SCP_COMMAND -o Port=$SSH -o User=$SSH_LOGIN 127.0.0.1:$ORIG $DEST +} + +# Copy files to the guest +function kvmx_scp_to { + if ! kvmx_running; then + echo "$BASENAME: guest $VM is not running" + exit 1 + fi + + ORIG="$3" + DEST="$4" + SSH="`cat $SSHFILE`" + + if [ -z "$DEST" ]; then + exit 1 + fi + + # Fix ~/ path + if echo $DEST | grep -q -e "^$HOME"; then + DEST="$(echo $DEST | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" + fi + + $SCP_COMMAND -o Port=$SSH -o User=$SSH_LOGIN $ORIG 127.0.0.1:$DEST +} + # List guests function kvmx_list { if [ -e "$GLOBAL_USER_CONFIG_FOLDER" ]; then |