vscode insiders connection error after update - ssh

Vscode insiders stopped to work with remote today morning after (unavoidble) update. It doesn't show remote directory, saying
Connection error: Unauthorized client refused.
and
Failed to connect to the remote extension host server (Error:
Connection error: Unauthorized client refused.)
Deletion of all remote vscode files and killing vscode processes didn't help.
The following transcript can be seen in Output tab:
remote-ssh#0.44.0
linux x64
SSH Resolver called for "ssh-remote+myserver", attempt 1
SSH Resolver called for host: myserver
Setting up SSH remote "myserver"
Using commit id "MYHASH" and quality "insider" for server
Testing ssh with ssh -V
ssh exited with code: 0
Got stderr from ssh: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
Install and start server if needed
> Found existing installation at /home/dimskraft/.vscode-server-insiders/bin/MYHASH...
> Found running server...
>
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>
> Checking server status with wget
> ==MY-GUID==
"install" terminal command done
Received install output: ==MY-GUID==
Server is listening on port 35693
Spawning tunnel with: "ssh" -L 127.0.0.1:35693:127.0.0.1:35693 -o ConnectTimeout=15 "myserver" bash << 'EOSSH'
echo -e 'Connected to SSH Host - Please do not close this terminal' && sleep infinity
EOSSH
> Connected to SSH Host - Please do not close this terminal
Spawned SSH tunnel between local port 35693 and remote port 35693
Waiting for ssh tunnel to be ready
Tunneling remote port 35693 to local port 35693
Resolved "ssh-remote+myserver" to "127.0.0.1:35693"
------

Downgrading to 1.36.0-insider helped

Related

ssh tunnel VNC server connection closed unexpectedly

I have to tunnel the VNC server(tightvnc-server) running on my local machine to a remote server, so at remote server can access my local machine without port forwarding on router(at local machine network).
Right now I am using the following command
ssh -R 5950:localhost:5900 user#remote.ddns.net
Where 5900 the vnc server port on my local machine. And I have to access the machine from remote server using the command localhost:5950. And when I try to connect using vnc viewer I am getting the error connection closed unexpectedly. Normally if no connection exist I was getting connection refused error. But here something is missing in tunneling. Can any please tell me what could be the reason.
You need to activate the remote desktop, running:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \ -activate -configure -access -on \ -restart -agent -privs -all
Then you can connected using VNC Viewer

How to double ssh with vscode

To ssh into a remote station I do the following:
ssh -L 4001:connect.iop.kcl.ac.uk:4000 username1#cana.host.institution
I'm then asked for a password which I enter, and I then do:
ssh -YX username2#otherserver.other.institution
and am asked for another password, after which I am where I want to be.
I want to set this up in vs code using the Remote-SSH extension but am running into difficulty
When I try and add the first step (ssh -L 4001:connect.iop.kcl.ac.uk:4000 username1#cana.host.institution), my config file looks as follows:
Host cana.iop.kcl.ac.uk
HostName cana.iop.kcl.ac.uk
LocalForward 4001:connect.iop.kcl.ac.uk:4000
User dmzromc
But when I try and connect I get the following error:
[16:23:45.992] Log Level: 3
[16:23:45.993] remote-ssh#0.49.0
[16:23:45.994] darwin x64
[16:23:45.995] SSH Resolver called for "ssh-remote+cana.host.institution", attempt 1
[16:23:45.995] SSH Resolver called for host: cana.host.institution
[16:23:45.995] Setting up SSH remote "cana.host.institution"
[16:23:46.020] Using commit id "78a4c91400152c0f27ba4d363eb56d2835f9903a" and quality "stable" for server
[16:23:46.023] Install and start server if needed
[16:23:46.031] Checking ssh with "ssh -V"
[16:23:46.071] > OpenSSH_7.9p1, LibreSSL 2.7.3
[16:23:46.075] Running script with connection command: ssh -T -D 55893 -o ConnectTimeout=15 cana.iop.kcl.ac.uk bash
[16:23:46.364] > /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.364] Got some output, clearing connection timeout
[16:23:46.835] "install" terminal command done
[16:23:46.835] Install terminal quit with output: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.836] Received install output: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.837] Stopped parsing output early. Remaining text: /Users/user1/.ssh/config line 15: Missing target argument.
[16:23:46.837] Failed to parse remote port from server output
[16:23:46.838] Resolver error:
[16:23:46.842] ------
Any advice much appreciated
I had the same issue when forwarding a database port and fixed it by manually editing my ssh config as follows:
BEFORE (using the problematic config that VSCode auto generates)
Host mysshhost
HostName mysshhost
LocalForward 5432:mydatabaseservername:5432
User myuserid
AFTER (works for me)
Host mysshhost
HostName mysshhost
LocalForward localhost:5432 mydatabaseservername:5432
User myuserid
So in your case, the config should look something like:
Host cana.iop.kcl.ac.uk
HostName cana.iop.kcl.ac.uk
LocalForward localhost:4001 connect.iop.kcl.ac.uk:4000
User dmzromc

SSH to remote server refused if done via GitLab CI

We have a RHEL 7 remote server where I created a dummy user called gitlabci.
While SSH'd into the remote server, I generated a public-private key pair (for use when grabbing files from GitLab)
Uploaded the public key as a deploy key for use later when we get our CI set up
Generated another public-private key pair in my local machine (for use when SSH'ing into the remote server from the GitLab Runner)
Added the public key to the remote server's authorized_keys
Added the private key to the project's CI environment variables
The idea is when the CI runs, the GitLab runner will SSH into the remote server as the gitlabci user I created then fetch the branch into the web directory using the deploy keys.
I thought I have set up the keys properly but whenever the runner tries to SSH, the connection gets refused.
$ which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )
...
$ eval $(ssh-agent -s)
Agent pid 457
$ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
Identity added: (stdin) (GitLab CI)
$ mkdir -p ~/.ssh
$ chmod 700 ~/.ssh
$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
$ ssh gitlabci#random.server.com
Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh: connect to host random.server.com port 22: Connection refused
ERROR: Job failed: exit code 1
When I tried to SSH into the remote server via GitBash on my local machine using the key pair I generated it did work.
$ ssh -i ~/.ssh/gitlabci gitlabci#random.server.com
Last login: Mon Nov 4 13:49:59 2019 from machine01.work.server.com
ssh: connect to host random.server.com port 22: Connection refused
"Connection refused" means that the ssh client transmitted a connection request to the named host and port, and it received in response a so-called "reset" packet, indicating that the remote server was refusing to accept the connection.
If you can connect to random.server.com from one host but get connection refused from another host, a few possible explanations come to mind:
You might have an entry in your .ssh/config file which substitutes a different name or address for random.server.com. For example, an entry like the following would cause ssh to connect to random2.server.com when you request random.server.com:
Host random.server.com
Hostname random2.server.com
The IP address lookup for "random.server.com" is returning the wrong address somehow, so ssh is trying to connect to the wrong server. For example, someone might have added an entry to /etc/hosts for that hostname.
Some firewall or other packet inspection software is interfering with the connection attempt by responding with a fake reset packet.

Remote debugging using gdbserver over ssh

I want to debug a process running on a remote box from my host box (I built the code on the host machine).
Both have linux type operating systems.
I seems I can only communicate to the remote box from the host box via ssh (I tested using telnet).
I have followed the following steps to set this up:
On the Remote box:
Stop the firewall service:
service firewall_service stop
Attach the process to gdbserver
--attach :remote_port process_id
On the Host box:
Set up port forwarding via ssh
sudo ssh remote_username#remote_ip -L host_port:localhost:remote_port
-f sleep 60m
Set up gdb to attach to a remote process:
gdb file.debug
(gdb) target remote remote_ip:remote_port
When I try to start the debugging on the host by running 'target remote remote_ip:remote_port' on the host box I get a 'Connection timedout' error.
Can you guys see anything I am doing wrong, anything to check or an alternative way to debug remotely over ssh I would be grateful.
Thanks
This command:
sudo ssh remote_username#remote_ip -L host_port:localhost:remote_port ...
forwards local host_port to remote_port on remote_ip's localhost. This is useful only if you could not just connect to remote_ip:remote_port directly (for example, if that port is blocked by firewall).
This command:
(gdb) target remote remote_ip:remote_port
asks GDB to connect to remote_port on remote_ip. But you said that you can only reach remote_ip via ssh, so it's not surprising that GDB times out.
What you want:
ssh remote_username#remote_ip -L host_port:localhost:remote_port ...
(gdb) target remote :host_port
In other words, you connect to local host_port, and ssh forwards that local connection to remote_ip:remote_port, where gdbserver is listening for it.

ssh connection refused from mac os x on connecting to a remote computer

I am running on Mac OS X 10.7.4.
I am unable to ssh to a remote computer, but when I do ssh user#localhost, it works fine.
The error displayed is
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to web.iiit.ac.in [14.139.82.8] port 22.
debug1: connect to address 14.139.82.8 port 22: Connection refused
ssh: connect to host web.iiit.ac.in port 22: Connection refused
I have enabled the root login in System Preferences and disabled firewall.
Also, ps aux | grep ssh shows ssh-agent, contains /usr/bin/ssh-agent -l and grep ssh in the output.
On doing sudo launchctl list|grep ssh it shows:
0 com.openssh.sshd
After this, sudo launchctl start com.openssh.sshd ; sudo launchctl list|grep ssh gives
45973 - com.openssh.sshd
Again, after checking sudo launchctl list|grep ssh after sometime, it again shows :
- 0 com.openssh.sshd
In system preferences -> sharing->enable remote login. It will fix it.
Wireless connections has well know problems with the SSH strict package receiving algorithm. I have the same problem with a WiMax connection. It would turn good if you can establish a VPN or any kind of tunnel to the server.
see also
this thread
Your remote host probably doesn't have an SSH server running (or, if it does, it's not listening on port 22).
Your tests (ps aux, launchctl etc) won't help - the issue is on the remote host, not the local (you've got an SSH client, because you can connect to localhost, but the remote host 14.139.82.8 isn't allowing connections on port 22).
When I ran in to this problem, I found that OpenSSH was not completely installed. Install it by typing into Terminal: sudo apt-get install openssh-client openssh-server
Also, check your firewall. The default SSH port is 22. Open that port.
clean known_hosts file and try again. Worked for me.