Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set tssh as vscode default tools when create a new remote window? #138

Open
wyjBot opened this issue Aug 20, 2024 · 10 comments
Open

Comments

@wyjBot
Copy link

wyjBot commented Aug 20, 2024

I have tried change ”remote.SSH.path“ to "C:\Users\wyjbot\AppData\Local\Microsoft\WinGet\Links\tssh.exe" .but it not work

@lonnywong
Copy link
Member

lonnywong commented Aug 20, 2024

What is your purpose of using tssh in vscode?

If you want to use trzsz in the vscode terminal, modifying remote.SSH.path is not supported. You can open a local shell first, and use tssh in the local shell to log in to the server, which will support trzsz.

If you want to use tssh's automated-interaction feature to log in to the server, you need to write a script and change remote.SSH.path to the script.

  • tssh.sh ( on MacOS, Linux, etc... )
#!/bin/bash

# vscode requires -V to output OpenSSH
if [[ " $@ " =~ " -V " ]]; then
  echo "OpenSSH"
  exit 0
fi

# replace -v with --debug
args=()
for arg in "$@"; do
  if [ "$arg" != "-v" ]; then
    args+=("$arg")
  else
    args+=("--debug")
  fi
done

# call tssh
tssh "${args[@]}"
  • tssh.bat ( on Windows )
@echo off
setlocal enabledelayedexpansion
rem vscode requires -V to output OpenSSH
for %%A in (%*) do (
    if "%%A"=="-V" (
        echo OpenSSH
        exit /b 0
    )
)
rem replace -v with --debug
set args=
for %%A in (%*) do (
    if "%%A"=="-v" (
        set args=!args! --debug
    ) else (
        set args=!args! %%A
    )
)
rem call tssh
tssh %args%

@wyjBot
Copy link
Author

wyjBot commented Aug 21, 2024

Is this normal on your win? I still can't bring up win11 file browser to upload. I suspect that vscode remote.SSH.path does not take effect

@lonnywong
Copy link
Member

If you want to use trzsz in the vscode terminal, modifying remote.SSH.path is not supported.

trzsz ( trz / tsz ) is not supported even you set remote.SSH.path to tssh.bat.

After you log in to the remote server in vscode, execute the following command in Windows PowerShell:

Get-WmiObject Win32_Process | Where-Object { $_.CommandLine -like '*tssh*' } | Select-Object ProcessId, CommandLine

You will see the output similar to this:

tssh -T -D 55648 xxx bash

When you open multiple remote terminals in vscode, the number of ssh processes will not increase.

That's because each terminal in vscode is implemented by vscode itself through -D dynamic port forwarding.

tssh cannot capture the input and output of each terminal in vscode, so it cannot support trzsz.

@wyjBot
Copy link
Author

wyjBot commented Aug 21, 2024

fine.

  1. I use my company's file transfer tool called "ift". it could use in vscode, I don't know detail about how it execute. the problem is it only available for company‘s server and need Employee authentication.

  2. just for using automated-interaction tssh.bat. it report below bug.

[10:58:44.985] "remote.SSH.path": D:\tssh.bat
[10:58:44.985] "remote.SSH.configFile": undefined
[10:58:44.985] "remote.SSH.useFlock": true
[10:58:44.985] "remote.SSH.lockfilesInTmp": false
[10:58:44.985] "remote.SSH.localServerDownload": auto
[10:58:44.985] "remote.SSH.remoteServerListenOnSocket": false
[10:58:44.985] "remote.SSH.showLoginTerminal": true
[10:58:44.986] "remote.SSH.defaultExtensions": []
[10:58:44.986] "remote.SSH.loglevel": 1
[10:58:44.986] "remote.SSH.enableDynamicForwarding": true
[10:58:44.986] "remote.SSH.enableRemoteCommand": false
[10:58:44.986] "remote.SSH.serverPickPortsFromRange": {}
[10:58:44.986] "remote.SSH.serverInstallPath": {}
[10:58:44.986] "remote.SSH.permitPtyAllocation": true
[10:58:44.986] "remote.SSH.preferredLocalPortRange: undefined
[10:58:44.986] "remote.SSH.useCurlAndWgetConfigurationFiles: false
[10:58:44.991] VS Code version: 1.92.0
[10:58:44.991] Remote-SSH version: [email protected]
[10:58:44.991] win32 x64
[10:58:44.999] SSH Resolver called for host: ptm
[10:58:44.999] Setting up SSH remote "ptm"
[10:58:45.002] Using commit id "b1c0a14de1414fcdaa400695b4db1c0799bc3124" and quality "stable" for server
[10:58:45.004] Install and start server if needed
[10:58:45.006] Checking ssh with "D:\tssh.bat -V"
[10:58:45.007] Finding installed ssh failed: spawn EINVAL
[10:58:45.008] Resolver error: Error: spawn EINVAL
	at ChildProcess.spawn (node:internal/child_process:421:11)
	at Object.spawn (node:child_process:799:9)
	at c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:589529
	at new Promise (<anonymous>)
	at R (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:589449)
	at k (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:589400)
	at A (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:592580)
	at T (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:589171)
	at C (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:589076)
	at t.generateMultiLineCommand (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:590768)
	at t.generateSshCommand (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:623446)
	at c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:582869
	at async t.withShowDetailsEvent (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:586054)
	at async k (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:579675)
	at async t.resolve (c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:583465)
	at async c:\Users\wyjbot\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.2024072315\out\extension.js:2:851047
[10:58:45.010] TELEMETRY: {"eventName":"resolver","properties":{"osReleaseId":"","arch":"","askedPw":"0","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","remoteInConfigFile":"1","gotUnrecognizedPrompt":"0","dynamicForwarding":"1","localServer":"0","didLocalDownload":"0","installUnpackCode":"0","outcome":"failure","reason":"Unknown","exitCodeLabel":""},"measures":{"resolveAttempts":1,"isExecServer":0,"timing.totalResolveTime":23}}
[10:58:45.012] ------

[10:58:45.245] Opening exec server for ssh-remote+ptm
[10:58:45.263] Initizing new exec server for ssh-remote+ptm
[10:58:45.264] Using commit id "b1c0a14de1414fcdaa400695b4db1c0799bc3124" and quality "stable" for server
[10:58:45.266] Install and start server if needed
[10:58:45.272] Checking ssh with "D:\tssh.bat -V"
[10:58:45.272] Finding installed ssh failed: spawn EINVAL
[10:58:45.273] Exec server for ssh-remote+ptm failed: Error: spawn EINVAL
[10:58:45.273] Error opening exec server for ssh-remote+ptm: Error: spawn EINVAL

@lonnywong
Copy link
Member

What will be the output of executing D:\tssh.bat -V in PowerShell?

@wyjBot
Copy link
Author

wyjBot commented Aug 21, 2024

OpenSSH

@lonnywong
Copy link
Member

The weird thing is that vscode will report an error spawn EINVAL.

It may be a permission issue, can you try C:\tssh.bat ?

@wyjBot
Copy link
Author

wyjBot commented Aug 21, 2024

even i directly run it in vsocde bottom terminal:

PS C:\Users\wyjbot> C:\tssh.bat -V                           
OpenSSH
PS C:\Users\wyjbot> D:\tssh.bat -V
OpenSSH

@lonnywong
Copy link
Member

The output OpenSSH is as expected, I mean try setting remote.SSH.path to C:\tssh.bat.

@lonnywong
Copy link
Member

  1. I use my company's file transfer tool called "ift". it could use in vscode, I don't know detail about how it execute. the problem is it only available for company‘s server and need Employee authentication.

The ift may not be implemented through the ssh connection, but through other connection and authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants