Skip to content

Instantly share code, notes, and snippets.

@GongT
Last active June 11, 2017 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GongT/cfb6305d8d587eceda6d3315357aed02 to your computer and use it in GitHub Desktop.
Save GongT/cfb6305d8d587eceda6d3315357aed02 to your computer and use it in GitHub Desktop.
from linux shell, remote open chrome on windows

On windows

create a link to chrome inside WSL. this will only run after Creators Update

echo '#!/bin/bash

cd /mnt/c
exec "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe" "$@"
' > /usr/local/bin/chrome
chmod a+x /usr/local/bin/chrome

create server keys:

cd /etc/ssh
ssh-keygen -A
rm -f *.pub
vi sshd_config

edit this, save.

Port 22
ListenAddress ::
ListenAddress 0.0.0.0

start sshd:

/usr/sbin/sshd

On Linux

save this file to /usr/local/bin/chrome.

#!/bin/bash

if [[ "$*" =~ "127.0.0.1" ]] || [[ "$*" =~ "localhost" ]] ; then
        ARGS=()
        HOST=$(hostname)
        for i in "$@"; do
                ARGS+=(\
$(echo "$i" | sed "s/^127.0.0.1$/$HOST/g;s/^localhost$/$HOST/g" )
                )
        done
else
        ARGS=("$@")
fi

/usr/local/bin/remote-open /usr/local/bin/chrome "${ARGS[@]}"

RUN:

echo -e '#!/bin/bash\n\nssh -i ~/.ssh/gongt.me-home $SSH_CLIENT_IP "$@"' > /usr/local/bin/remote-open
chmod a+x /usr/local/bin/remote-open /usr/local/bin/chrome

($SSH_CLIENT_IP comes from linux tool box)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment