jeanp413 / open-remote-ssh

VSCode Remote Development: Open any folder on a remote machine using SSH.
MIT License
309 stars 43 forks source link

Error: Encrypted OpenSSH private key detected, but no passphrase given #126

Open BackMountainDevil opened 11 months ago

BackMountainDevil commented 11 months ago

version

issue intro

I can login to 144 server by ssh 144 and input passphrase. But I tried open-remote-ssh to connect to 144, it did not provide me a passphrase input panel while it provide a password input panel. Server not privide password auth way for security reason.

wired thing got, I have another server using passphrase, such as hp6( I can ssh to it too). open-remote-ssh did provide me a passphrase input panel on this server. and failed by other reason

If I tried open-remote-ssh to connect to a server without passphrase just use key. It work.

ps: refer to #32 , I tried code-oss, that was worse.

log detail at 144

[Info  - 01:43:39.507] Resolving ssh remote authority 'ssh-remote+144' (attemp #1)
[Error  - 01:43:39.520] Error while parsing SSH public key /home/kearney/.ssh/id_rsaServer:
Error: Encrypted OpenSSH private key detected, but no passphrase given
    at q.parse (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:358205)
    at Object.ee [as parseKey] (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:366752)
    at /home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:442957
    at Array.map (<anonymous>)
    at t.gatherIdentityFiles (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:442896)
    at async /home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:403197
[Error  - 01:43:39.520] Couldn't get identities from OpenSSH agent
Error: SSH_AUTH_SOCK environment variable not defined
    at t.gatherIdentityFiles (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:443262)
    at async /home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:403197
[Trace  - 01:43:39.520] Identity keys:
None
[Info  - 01:43:39.558] Trying no-auth authentication
[Info  - 01:43:39.611] Trying password authentication
[Trace  - 01:43:44.246] Server install command:
# Server installation script

TMP_DIR="${XDG_RUNTIME_DIR:-"/tmp"}"

DISTRO_VERSION="1.85.1"
DISTRO_COMMIT="08e6c15293922dd53a864bb041be381322fee401"
DISTRO_QUALITY="stable"
DISTRO_VSCODIUM_RELEASE="23348"

SERVER_APP_NAME="codium-server"
SERVER_INITIAL_EXTENSIONS=""
SERVER_LISTEN_FLAG="--port=0"
SERVER_DATA_DIR="$HOME/.vscodium-server"
SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"
SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"
SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"
SERVER_PIDFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.pid"
SERVER_TOKENFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.token"
SERVER_ARCH=
SERVER_CONNECTION_TOKEN=
SERVER_DOWNLOAD_URL=

LISTENING_ON=
OS_RELEASE_ID=
ARCH=
PLATFORM=

# Mimic output from logs of remote-ssh extension
print_install_results_and_exit() {
    echo "fc6618c933bd3c8d6c17992f: start"
    echo "exitCode==$1=="
    echo "listeningOn==$LISTENING_ON=="
    echo "connectionToken==$SERVER_CONNECTION_TOKEN=="
    echo "logFile==$SERVER_LOGFILE=="
    echo "osReleaseId==$OS_RELEASE_ID=="
    echo "arch==$ARCH=="
    echo "platform==$PLATFORM=="
    echo "tmpDir==$TMP_DIR=="

    echo "fc6618c933bd3c8d6c17992f: end"
    exit 0
}

# Check if platform is supported
KERNEL="$(uname -s)"
case $KERNEL in
    Darwin)
        PLATFORM="darwin"
        ;;
    Linux)
        PLATFORM="linux"
        ;;
    FreeBSD)
        PLATFORM="freebsd"
        ;;
    DragonFly)
        PLATFORM="dragonfly"
        ;;
    *)
        echo "Error platform not supported: $KERNEL"
        print_install_results_and_exit 1
        ;;
esac

# Check machine architecture
ARCH="$(uname -m)"
case $ARCH in
    x86_64 | amd64)
        SERVER_ARCH="x64"
        ;;
    armv7l | armv8l)
        SERVER_ARCH="armhf"
        ;;
    arm64 | aarch64)
        SERVER_ARCH="arm64"
        ;;
    ppc64le)
        SERVER_ARCH="ppc64le"
        ;;
    *)
        echo "Error architecture not supported: $ARCH"
        print_install_results_and_exit 1
        ;;
esac

# https://www.freedesktop.org/software/systemd/man/os-release.html
OS_RELEASE_ID="$(grep -i '^ID=' /etc/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
if [[ -z $OS_RELEASE_ID ]]; then
    OS_RELEASE_ID="$(grep -i '^ID=' /usr/lib/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
    if [[ -z $OS_RELEASE_ID ]]; then
        OS_RELEASE_ID="unknown"
    fi
fi

# Create installation folder
if [[ ! -d $SERVER_DIR ]]; then
    mkdir -p $SERVER_DIR
    if (( $? > 0 )); then
        echo "Error creating server install directory"
        print_install_results_and_exit 1
    fi
fi

SERVER_DOWNLOAD_URL="$(echo "https://github.com/VSCodium/vscodium/releases/download/\${version}.\${release}/vscodium-reh-\${os}-\${arch}-\${version}.\${release}.tar.gz" | sed "s/\${quality}/$DISTRO_QUALITY/g" | sed "s/\${version}/$DISTRO_VERSION/g" | sed "s/\${commit}/$DISTRO_COMMIT/g" | sed "s/\${os}/$PLATFORM/g" | sed "s/\${arch}/$SERVER_ARCH/g" | sed "s/\${release}/$DISTRO_VSCODIUM_RELEASE/g")"

# Check if server script is already installed
if [[ ! -f $SERVER_SCRIPT ]]; then
    if [[ "$PLATFORM" != "darwin" ]] && [[ "$PLATFORM" != "linux" ]]; then
        echo "Error "$PLATFORM" needs manual installation of remote extension host"
        print_install_results_and_exit 1
    fi

    pushd $SERVER_DIR > /dev/null

    if [[ ! -z $(which wget) ]]; then
        wget --tries=3 --timeout=10 --continue --no-verbose -O vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    elif [[ ! -z $(which curl) ]]; then
        curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    else
        echo "Error no tool to download server binary"
        print_install_results_and_exit 1
    fi

    if (( $? > 0 )); then
        echo "Error downloading server from $SERVER_DOWNLOAD_URL"
        print_install_results_and_exit 1
    fi

    tar -xf vscode-server.tar.gz --strip-components 1
    if (( $? > 0 )); then
        echo "Error while extracting server contents"
        print_install_results_and_exit 1
    fi

    if [[ ! -f $SERVER_SCRIPT ]]; then
        echo "Error server contents are corrupted"
        print_install_results_and_exit 1
    fi

    rm -f vscode-server.tar.gz

    popd > /dev/null
else
    echo "Server script already installed in $SERVER_SCRIPT"
fi

# Try to find if server is already running
if [[ -f $SERVER_PIDFILE ]]; then
    SERVER_PID="$(cat $SERVER_PIDFILE)"
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"
else
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -A | grep $SERVER_SCRIPT | grep -v grep)"
fi

if [[ -z $SERVER_RUNNING_PROCESS ]]; then
    if [[ -f $SERVER_LOGFILE ]]; then
        rm $SERVER_LOGFILE
    fi
    if [[ -f $SERVER_TOKENFILE ]]; then
        rm $SERVER_TOKENFILE
    fi

    touch $SERVER_TOKENFILE
    chmod 600 $SERVER_TOKENFILE
    SERVER_CONNECTION_TOKEN="b3caf8ce-2f53-41d9-88d9-6020d924a7e0"
    echo $SERVER_CONNECTION_TOKEN > $SERVER_TOKENFILE

    $SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &
    echo $! > $SERVER_PIDFILE
else
    echo "Server script is already running $SERVER_SCRIPT"
fi

if [[ -f $SERVER_TOKENFILE ]]; then
    SERVER_CONNECTION_TOKEN="$(cat $SERVER_TOKENFILE)"
else
    echo "Error server token file not found $SERVER_TOKENFILE"
    print_install_results_and_exit 1
fi

if [[ -f $SERVER_LOGFILE ]]; then
    for i in {1..5}; do
        LISTENING_ON="$(cat $SERVER_LOGFILE | grep -E 'Extension host agent listening on .+' | sed 's/Extension host agent listening on //')"
        if [[ -n $LISTENING_ON ]]; then
            break
        fi
        sleep 0.5
    done

    if [[ -z $LISTENING_ON ]]; then
        echo "Error server did not start sucessfully"
        print_install_results_and_exit 1
    fi
else
    echo "Error server log file not found $SERVER_LOGFILE"
    print_install_results_and_exit 1
fi

# Finish server setup
print_install_results_and_exit 0

[Trace  - 01:44:27.795] Server install command stderr:
No data received.
failed: Connection timed out.
failed: Connection timed out.
failed: Connection timed out.

[Trace  - 01:44:27.795] Server install command stdout:
Error downloading server from https://github.com/VSCodium/vscodium/releases/download/1.85.1.23348/vscodium-reh-linux-x64-1.85.1.23348.tar.gz
fc6618c933bd3c8d6c17992f: start
exitCode==1==
listeningOn====
connectionToken====
logFile==/home/yicairun/.vscodium-server/.08e6c15293922dd53a864bb041be381322fee401.log==
osReleaseId==ubuntu==
arch==x86_64==
platform==linux==
tmpDir==/run/user/1021==
fc6618c933bd3c8d6c17992f: end

[Error  - 01:44:27.796] Error resolving authority
Error: Couldn't install vscode server on remote server, install script returned non-zero exit status
    at t.installCodeServer (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:441144)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:404941

log detail at hp6

[Info  - 02:10:01.173] Resolving ssh remote authority 'ssh-remote+hp6' (attemp #1)
[Error  - 02:10:01.187] Couldn't get identities from OpenSSH agent
Error: SSH_AUTH_SOCK environment variable not defined
    at t.gatherIdentityFiles (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:443262)
    at async /home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:403197
[Trace  - 02:10:01.188] Identity keys:
/home/kearney/.ssh/id_ed25519_hp6 ssh-ed25519 SHA256:*********************nkrcQ8T*******rA40=
[Info  - 02:10:01.470] Trying no-auth authentication
[Info  - 02:10:01.709] Trying publickey authentication: /home/kearney/.ssh/id_ed25519_hp6 ssh-ed25519 SHA256:*********************nkrcQ8T*******rA40=
[Trace  - 02:10:05.36] Server install command:

# Server installation script

TMP_DIR="${XDG_RUNTIME_DIR:-"/tmp"}"

DISTRO_VERSION="1.85.1"
DISTRO_COMMIT="08e6c15293922dd53a864bb041be381322fee401"
DISTRO_QUALITY="stable"
DISTRO_VSCODIUM_RELEASE="23348"

SERVER_APP_NAME="codium-server"
SERVER_INITIAL_EXTENSIONS=""
SERVER_LISTEN_FLAG="--port=0"
SERVER_DATA_DIR="$HOME/.vscodium-server"
SERVER_DIR="$SERVER_DATA_DIR/bin/$DISTRO_COMMIT"
SERVER_SCRIPT="$SERVER_DIR/bin/$SERVER_APP_NAME"
SERVER_LOGFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.log"
SERVER_PIDFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.pid"
SERVER_TOKENFILE="$SERVER_DATA_DIR/.$DISTRO_COMMIT.token"
SERVER_ARCH=
SERVER_CONNECTION_TOKEN=
SERVER_DOWNLOAD_URL=

LISTENING_ON=
OS_RELEASE_ID=
ARCH=
PLATFORM=

# Mimic output from logs of remote-ssh extension
print_install_results_and_exit() {
    echo "9d49f1601545e8ee347bc640: start"
    echo "exitCode==$1=="
    echo "listeningOn==$LISTENING_ON=="
    echo "connectionToken==$SERVER_CONNECTION_TOKEN=="
    echo "logFile==$SERVER_LOGFILE=="
    echo "osReleaseId==$OS_RELEASE_ID=="
    echo "arch==$ARCH=="
    echo "platform==$PLATFORM=="
    echo "tmpDir==$TMP_DIR=="

    echo "9d49f1601545e8ee347bc640: end"
    exit 0
}

# Check if platform is supported
KERNEL="$(uname -s)"
case $KERNEL in
    Darwin)
        PLATFORM="darwin"
        ;;
    Linux)
        PLATFORM="linux"
        ;;
    FreeBSD)
        PLATFORM="freebsd"
        ;;
    DragonFly)
        PLATFORM="dragonfly"
        ;;
    *)
        echo "Error platform not supported: $KERNEL"
        print_install_results_and_exit 1
        ;;
esac

# Check machine architecture
ARCH="$(uname -m)"
case $ARCH in
    x86_64 | amd64)
        SERVER_ARCH="x64"
        ;;
    armv7l | armv8l)
        SERVER_ARCH="armhf"
        ;;
    arm64 | aarch64)
        SERVER_ARCH="arm64"
        ;;
    ppc64le)
        SERVER_ARCH="ppc64le"
        ;;
    *)
        echo "Error architecture not supported: $ARCH"
        print_install_results_and_exit 1
        ;;
esac

# https://www.freedesktop.org/software/systemd/man/os-release.html
OS_RELEASE_ID="$(grep -i '^ID=' /etc/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
if [[ -z $OS_RELEASE_ID ]]; then
    OS_RELEASE_ID="$(grep -i '^ID=' /usr/lib/os-release 2>/dev/null | sed 's/^ID=//gi' | sed 's/"//g')"
    if [[ -z $OS_RELEASE_ID ]]; then
        OS_RELEASE_ID="unknown"
    fi
fi

# Create installation folder
if [[ ! -d $SERVER_DIR ]]; then
    mkdir -p $SERVER_DIR
    if (( $? > 0 )); then
        echo "Error creating server install directory"
        print_install_results_and_exit 1
    fi
fi

SERVER_DOWNLOAD_URL="$(echo "https://github.com/VSCodium/vscodium/releases/download/\${version}.\${release}/vscodium-reh-\${os}-\${arch}-\${version}.\${release}.tar.gz" | sed "s/\${quality}/$DISTRO_QUALITY/g" | sed "s/\${version}/$DISTRO_VERSION/g" | sed "s/\${commit}/$DISTRO_COMMIT/g" | sed "s/\${os}/$PLATFORM/g" | sed "s/\${arch}/$SERVER_ARCH/g" | sed "s/\${release}/$DISTRO_VSCODIUM_RELEASE/g")"

# Check if server script is already installed
if [[ ! -f $SERVER_SCRIPT ]]; then
    if [[ "$PLATFORM" != "darwin" ]] && [[ "$PLATFORM" != "linux" ]]; then
        echo "Error "$PLATFORM" needs manual installation of remote extension host"
        print_install_results_and_exit 1
    fi

    pushd $SERVER_DIR > /dev/null

    if [[ ! -z $(which wget) ]]; then
        wget --tries=3 --timeout=10 --continue --no-verbose -O vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    elif [[ ! -z $(which curl) ]]; then
        curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL
    else
        echo "Error no tool to download server binary"
        print_install_results_and_exit 1
    fi

    if (( $? > 0 )); then
        echo "Error downloading server from $SERVER_DOWNLOAD_URL"
        print_install_results_and_exit 1
    fi

    tar -xf vscode-server.tar.gz --strip-components 1
    if (( $? > 0 )); then
        echo "Error while extracting server contents"
        print_install_results_and_exit 1
    fi

    if [[ ! -f $SERVER_SCRIPT ]]; then
        echo "Error server contents are corrupted"
        print_install_results_and_exit 1
    fi

    rm -f vscode-server.tar.gz

    popd > /dev/null
else
    echo "Server script already installed in $SERVER_SCRIPT"
fi

# Try to find if server is already running
if [[ -f $SERVER_PIDFILE ]]; then
    SERVER_PID="$(cat $SERVER_PIDFILE)"
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -p $SERVER_PID | grep $SERVER_SCRIPT)"
else
    SERVER_RUNNING_PROCESS="$(ps -o pid,args -A | grep $SERVER_SCRIPT | grep -v grep)"
fi

if [[ -z $SERVER_RUNNING_PROCESS ]]; then
    if [[ -f $SERVER_LOGFILE ]]; then
        rm $SERVER_LOGFILE
    fi
    if [[ -f $SERVER_TOKENFILE ]]; then
        rm $SERVER_TOKENFILE
    fi

    touch $SERVER_TOKENFILE
    chmod 600 $SERVER_TOKENFILE
    SERVER_CONNECTION_TOKEN="f5aebba2-464b-4163-834e-7e16ef5348f7"
    echo $SERVER_CONNECTION_TOKEN > $SERVER_TOKENFILE

    $SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &
    echo $! > $SERVER_PIDFILE
else
    echo "Server script is already running $SERVER_SCRIPT"
fi

if [[ -f $SERVER_TOKENFILE ]]; then
    SERVER_CONNECTION_TOKEN="$(cat $SERVER_TOKENFILE)"
else
    echo "Error server token file not found $SERVER_TOKENFILE"
    print_install_results_and_exit 1
fi

if [[ -f $SERVER_LOGFILE ]]; then
    for i in {1..5}; do
        LISTENING_ON="$(cat $SERVER_LOGFILE | grep -E 'Extension host agent listening on .+' | sed 's/Extension host agent listening on //')"
        if [[ -n $LISTENING_ON ]]; then
            break
        fi
        sleep 0.5
    done

    if [[ -z $LISTENING_ON ]]; then
        echo "Error server did not start sucessfully"
        print_install_results_and_exit 1
    fi
else
    echo "Error server log file not found $SERVER_LOGFILE"
    print_install_results_and_exit 1
fi

# Finish server setup
print_install_results_and_exit 0

[Trace  - 02:10:38.334] Server install command stderr:
failed: Connection timed out.
failed: Connection timed out.
failed: Connection timed out.

[Trace  - 02:10:38.334] Server install command stdout:
Error downloading server from https://github.com/VSCodium/vscodium/releases/download/1.85.1.23348/vscodium-reh-linux-x64-1.85.1.23348.tar.gz
9d49f1601545e8ee347bc640: start
exitCode==1==
listeningOn====
connectionToken====
logFile==/home/mifen/.vscodium-server/.08e6c15293922dd53a864bb041be381322fee401.log==
osReleaseId==endeavouros==
arch==x86_64==
platform==linux==
tmpDir==/run/user/1000==
9d49f1601545e8ee347bc640: end

[Error  - 02:10:38.334] Error resolving authority
Error: Couldn't install vscode server on remote server, install script returned non-zero exit status
    at t.installCodeServer (/home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:441144)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/kearney/.vscode-oss/extensions/jeanp413.open-remote-ssh-0.0.45-universal/out/extension.js:1:404941
BackMountainDevil commented 11 months ago

about hp6 failed may caused by network reason. I can download vscodium-reh-linux-x64-1.85.1.23348.tar.gz and put it there and tar -xf vscode-server.tar.gz --strip-components 1.