diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec
index 58e6b162..fc217e3e 100755
--- a/cdist/conf/type/__install_config/files/remote/exec
+++ b/cdist/conf/type/__install_config/files/remote/exec
@@ -35,7 +35,10 @@ target_host="$__target_host"
 shift
 
 ssh="ssh -o User=root -q $target_host"
-code="$ssh chroot $chroot sh -c '$@'"
+
+# escape ' with '"'"'
+code="$(echo "$@" | sed -e "s/'/'\"'\"'/g")"
+code="$ssh chroot $chroot sh -c '$code'"
 
 log "target_host: $target_host"
 log "chroot: $chroot"