VSCode Remote SSH to Linux - Connecting was canceled - vscode-remote

I am trying to connect from my Windows 10 machine to my Ubuntu Linux server (16.04.6) using Remote SSH.
To do this I've read many different tutorials but have no success.
I am able to connect from my Windows 10 command prompt to the Ubuntu Linux server via ssh without any problems. I even used ssh-keygen to generate a private and a public key and copied the public key to the appropriate directory on the Linux Server (.ssh).
In VsCode I installed the extension Remote-SSH added my host to my configuration file c:\user.ssh\config:
Host <ip-address>
HostName <ip-address>
User <username>
Then I clicked in VSCode the button bottom left "Open a remote Window" and chosed my host. A new windows opens and VSCode is trying to connect. Then I see a window with the error message: "Could not establish connection to . Connection was canceled". This is the log.
[11:53:17.573] Log Level: 2
[11:53:17.582] remote-ssh#0.51.0
[11:53:17.583] win32 x64
[11:53:17.586] SSH Resolver called for "ssh-remote+<ip-address>", attempt 1
[11:53:17.587] SSH Resolver called for host: <ip-address>
[11:53:17.587] Setting up SSH remote "<ip-address>"
[11:53:17.648] Using commit id "5763d909d5f12fe19f215cbfdd29a91c0fa9208a" and quality "stable" for server
[11:53:17.650] Install and start server if needed
[11:53:18.624] getPlatformForHost was canceled
[11:53:18.625] Resolver error: Connecting was canceled
[11:53:18.640] ------
Again, I can connect to the same linux server via ssh from my local machine (Win 10) without any problems.

I've resolved the connection issues; possibly the ssh config was not correctly saved/accessed by VS Code?
I thought I should be able to directly set it up to point to an existing config file, but that didn't seem to work. Instead, I created a new config file in the UI, and over-wrote the contents. Shouldn't be necessary, but seemed to do the trick.
What I did was:
Add new host: => Remote-SSH: Connect to host... => Add New SSH Host...
Type in command: ssh user#host to attempt to connect
Choose platform in the command bar in the new window (Linux in my case)
Verify connected (I needed to change ssh-agent settings to store credentials)
Edit the config location: => Remote-SSH: Connect to host... => Settings
Enter config file under Remote.SSH: Config File (C:\Users\me\.vagrant\machines\default\virtualbox\config in my case)
Modify config file further, as needed
Connect through the UI: Remote-SSH: Connect to host... =>
Hope that helps!

For me it was not starting necessary SSH*. See status services using:
Get-Service SSH* on PowerShell.
I got a time out error on enabling necessary services and this helped.

A colleague of mine was with this problem. We solved just deleting his %USERPROFILE\.ssh\config file, closing VSCode, reopening it, and trying to connect again.
There was some garbage in his ssh config file.

I also found that if the value of the "Host" field includes a ")" character, then there will be an error message as follows and the VSCode keeps trying opening remote:
The terminal process "C:\WINDOWS\System32\cmd.exe /c (type "C:\Users\xxxxx_xxxxx\AppData\Local\Temp\vscode-linux-multi-line-command--ccton_---_---2-705401992.sh" | ssh -T -L 127.0.0.1:53080:/run/user/1000/vscode-ssh-remote-server-sock-1636523090 Accton_AWS_EC)2 bash) & exit /b 0" terminated with exit code: 1.

I tried the following that worked for me:
Click on View > Command Palette (alternatively press CTRL + Shift + P)
Start typing:
Remote SSH: Kill
Click on the first option that says: Remote-SSH: kill VS Code Server on Host...
From the options, click on the server you are having trouble connecting to. This will kill that VScode server.
Now just try to reconnect:
a. View > Command Palette (alternatively press CTRL + Shift + P)
b. Start typing:
SSH Remote-SSH: Connect to host...
c. Select the server.

Adding my 2 cents here, I too had lots of trouble connecting to a remote using "Remote SSH Extension of Microsoft". Unfortunately, no luck and spent a lot of time trying all ways possible.
I found another extension named "SSH Client" by cweijan. It was easy and I was able to access my remote using it.

When I had this issue it was because the extension was complaining that the pem file permissions were too open, it should be accessible just by my current user.

Yes, I would like to ~ add on top of Shivam Popat's answer.
Configure F1 ssh.add and Option to add client, and password appears.
Now, connect, and save.
From the left pane you would see icon of key. and upon clicking it will open the remote folders.
The previous problem with VScode remote SSH resolved.

Related

VSCode SSH connection can't see the program but remote terminal can

I work on an HPC cluster. I added my cluster .bashrc ml load git.2.foobar. When I connect to the host on VSCode, it tells me to update my git1.8.
But when I open a terminal on Vscode, git --version returns the one on bashrc.
What is going on?
Thanks!
I also tried adding the ml command to .bash_profile, which didn't fix the issue. I also closed and reopended the host connection to re-source it.

Uiautomatorviewer Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist

i can launch Uiautomatorviewer sucessfully, inspect any page/app at personal profile.
Once phone at work profile/launching any app installed under work profile then Uiautomatorviewer throws error:
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!
i am not sure why it behave like this suddenly, it used to work regardless personal / work profile last week.
i don't remember i change any configuration...
please help to give me clues why? i have followed many previous post suggestion to restart adb server, kill appium server, restart phone/laptop, disable enable developer options...etc. none works....
I tried to inspect personal profile now, the same error occurred:
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!
updated: i used appium studio inspector and it works. I still not sure what happened to adb or uiautomator via command line? how do i debug it?
found an answer
com.android.ddmlib.SyncException: Is a directory
try doing adb shell rm -rf /data/local/tmp and rebooting the phone first. it's ok if you get rm: /data/local/tmp: Permission denied. ignore it - it's for the tmp folder itself after its content was already removed (that's what you need anyway)

Failed to load resource: net::ERR_CONNECTION_TIMED_OUT on remote but works fine on localhost

i have react with asp.net core website . it worked fine on localhost but when published on iis remote server the timeout error occurs.
the front-end (react client) and back-end(server) asp.netcore webapi work independently.
before uploading i changed the following in program.cs in webapi.
usUrl("https://localhost:4000")
to useUrl("https://www.virtualcollege.pk:4000")
i also changed the front-end baseurl similarly.
moreover, the connectionstrings in appsettings.json is correct for both databases.
i added migration and updated the databases successfully.
the website is live but timeout error occur :
virtualcollege.pk
i also tried the url with "https://myip-address:4000"
thanks in advance for help.
if i remove port number from url and publish on local folder than upload to remote server . the webapi.exe on local machine runs as follows:
You have to open incoming request for 4000 port. Try some methods below.
Windows Server
Please check this link or this one
Ubuntu/Debian
sudo ufw allow 4000/tcp
sudo ufw status // check status
CentOS
First, you should disable selinux, edit file /etc/sysconfig/selinux so it looks like this:
SELINUX=disabled
SELINUXTYPE=targeted
Save file and restart system.
Then you can add the new rule to iptables:
iptables -A INPUT -m state --state NEW -p tcp --dport 4000 -j ACCEPT
and restart iptables with /etc/init.d/iptables restart

Ubuntu 18.04 issue with xrdp and user

Since morning I am facing some issue with the ubuntu xrdp. I have 3 users server, admin and root. server user is once which is configured during the installation. if is use root user then I am able to login but if I use other server its throw following error.
connecting to sesman ip 127.0.0.1
sesman connect ok
sending login info to session manager, please wait...
login successful for display 10
started connecting
connection problem, giving up
some problem
for admin user its show following error
Unable to determine failsafe session name. Possible causes:
xfconfd isn`t running ( D-Bus setup problem) environment variable $XDG_CONFIG_DIRS is set incorrectly (must include */ etc") or xfce4-session is installed incorrectly.
My Ubuntu version is: Ubuntu 18.04.4 LTS
It`s fresh setup and i also try to reinstall xrdp and its dependency packages but nothing works.
The output of $echo $XDG_CONFIG_DIRS is empty.
After digging in deep and doing lots of troubleshooting, I finally able to access RDP from other users also. I reinstall everything and then install vncserver and kill all the running process of xface from the terminal. Now it's working.

Mesosphere installation PermissionError:/genconf/config.yaml

I got a Mesosphere-EE, and install on fedora 23 server (kernel 4.4)with:
$bash dcos_generate_config.ee.sh --web –v
then output:
Running mesosphere/dcos-genconf docker with BUILD_DIR set to/home/mesos-ee/genconf
Usage of loopback devices is strongly discouraged for production use.Either use `--storage-opt dm.thinpooldev` or use `--storage-opt
dm.no_warn_on_loop_devices=true` to suppress this warning.
07:53:46:: Logger set to DEBUG
07:53:46:: ====> Starting DCOS installer in web mode
07:53:46:: DCOS Installer v1
07:53:46:: Starting server ('0.0.0.0', 9000)
Then I start firefox though vnc, the vnc is on root. then:
07:53:57:: Root page requested. 07:53:57:: Serving/usr/local/lib/python3.4/site-packages/dcos_installer/templates/index.html
07:53:58:: Request for configuration type made.
07:53:58::Configuration file not found, /genconf/config.yaml. Writing new onewith all defaults.
07:53:58:: Error handling request
PermissionError: [Errno 13] Permission denied: '/genconf/config.yaml'
But I already have a genconf/config.yaml, it look like:
bootstrap_url: http://<bootstrap_public_ip>:<your_port>
cluster_name: '<cluster-name>'
exhibitor_storage_backend: zookeeper
exhibitor_zk_hosts: <host1>:2181,<host2>:2181,<host3>:2181
exhibitor_zk_path: /dcos
master_discovery: static
master_list:
- <master-private-ip-1>
- <master-private-ip-2>
- <master-private-ip-3>
superuser_username: <username>
superuser_password_hash: <hashed-password>
resolvers:
- 8.8.8.8
- 8.8.4.4
I do not know what’s going on. If you have any idear, please let me know, thank you very much!
Disable Selinux!
Configure SELINUX=disabled in the /etc/selinux/config file and then reboot!
Be ensure the selinux is disabled by the command getenforce.
$ getenforce
Disabled
zhe.
Correctly installing the enterprise edition depends on the correct system prerequisites. Anyway I suppose you're still on the bootstrap node so I will give you some path to succed in your current task.
Run the script as root or as a user issuing sudo dcos_generate_config.ee.sh
The script will also generate the config file automatically; if you want to use your own configuration file then create a folder named genconf and put it inside before running the script. You should changes the values inside <> with your specific configuration. If you need more help for your specific case send me an email to infofs2 at gmail.com

Resources