How to use non 22 ssh port in visual studio code insiders remote developments? - visual-studio-code

ssh login by authentication is working fine.
C:\Users\${DEVELOPER_NAME}>ssh ${HOST_IP_ADDRESS} -l ${DEVELOPER_NAME} -p ${SSHD_PORT} -i D:\prefix\PuTTY\${OPENSSH_FORMAT_PRIVATE_KEY}
Last login: Sun May 5 15:27:50 2019 from 10.40.171.44
Welcome to ...
[${DEVELOPER_NAME}#${HOST_AKA} ~]$
but sshd is running on 36000 not default 22 port, how can I tell that to vs code remote-ssh plugin
Host ${DEVELOPER_NAME}#${HOST_IP_ADDRESS}
HostName ${HOST_IP_ADDRESS}:${SSHD_PORT}
User ${DEVELOPER_NAME}
Port ${SSHD_PORT}
IdentityFile D:\prefix\PuTTY\${OPENSSH_FORMAT_PRIVATE_KEY}
this way gives me
Can't connect to ${DEVELOPER_NAME}#${HOST_IP_ADDRESS}: unreachable or not Linux x86_64 (ssh: connect to host ${HOST_IP_ADDRESS} port 22: Connection refused)
and
${DEVELOPER_NAME}#${HOST_IP_ADDRESS}:${SSHD_PORT}
in Remote-SSH: Connect to Host... gives me
Can't connect to ${DEVELOPER_NAME}#${HOST_IP_ADDRESS}:${SSHD_PORT}: unreachable or not Linux x86_64 (ssh: Could not resolve hostname ${HOST_IP_ADDRESS}:${SSHD_PORT}: Name or service not known)

Thanks to your question, I solved it. You may have already figured it out ... You do not need to add a port for HostName. Just write Port and it works.
Host ${HOST_NICKNAME}
User ${USER_ID_HOST}
HostName ${HOST_IP_ADDRESS}
Port ${SSHD_PORT}
IdentityFile ~/.ssh/id_rsa-remote-ssh

Related

my github ssh behavior didn't match the config

I want to use 443 port to connect to github.
So I add blow code into ~/.ssh/config
Host github.com
HostName ssh.github.com
User git
IdentityFile ~/.ssh/id_rsa.github
Port 443
But It didn't work.
some try:
first, I try ssh -v git#ssh.github.com
OpenSSH_9.2p1, OpenSSL 3.0.8 7 Feb 2023
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to ssh.github.com [20.205.243.160] port 22.
It show that, connection still use port 22.
and then I try ssh -v git#ssh.github.com -p 443
OpenSSH_9.2p1, OpenSSL 3.0.8 7 Feb 2023
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to ssh.github.com [20.205.243.160] port 443.
...
debug1: No more authentication methods to try.
git#ssh.github.com: Permission denied (publickey).
It show that, connection didn't find my publickey.
So finally I try ssh -v git#ssh.github.com -p 443 -i ~/.ssh/id_rsa.github
...
Connection to ssh.github.com closed.
Transferred: sent 3460, received 2724 bytes, in 0.8 seconds
Bytes per second: sent 4383.9, received 3451.4
debug1: Exit status 1
The connection is correct.
Besides, others config in my ~/.ssh/config work.
To use your Host config setting, you need to use your Host section name
ssh -Tv github.com
(no need for git#, since you have a User git in your config file Host github.com section)
Then you can check it uses the right port and private key.

Rancher desktop error when starting kubernetes

My Rancher desktop was working just fine, until today when I switched container runtime from containerd to dockerd. When I wanted to change it back to containerd, it says:
Error Starting Kubernetes
Error: unable to verify the first certificate
Some recent logfile lines:
client-key-data: LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUV1eXhYdFYvTDZOQmZsZVV0Mnp5ekhNUmlzK2xXRzUxUzBlWklKMmZ5MHJvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFNGdQODBWNllIVzBMSW13Q3lBT2RWT1FzeGNhcnlsWU8zMm1YUFNvQ2Z2aTBvL29UcklMSApCV2NZdUt3VnVuK1liS3hEb0VackdvbTJ2bFJTWkZUZTZ3PT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
2022-09-02T13:03:15.834Z: Error starting lima: Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
at TLSSocket.emit (node:events:390:28)
at TLSSocket._finishInit (node:_tls_wrap:944:8)
at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) {
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}
Tried reinstalling, factory reset etc. but no luck. I am using 1.24.4 verison.
TLDR: Try turning off Docker/Something that is binding to port 6443. Reset Kubernetes in Rancher Desktop, then try again.
Try checking if there is anything else listening on port 6443 which is needed by kubernetes:rancher-desktop.
In my case, lsof -i :6443 gave me...
~ lsof -i :6443
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.docke 63385 ~~~~~~~~~~~~ 150u IPv4 0x44822db677e8e087 0t0 TCP localhost:sun-sr-https (LISTEN)
ssh 82481 ~~~~~~~~~~~~ 27u IPv4 0x44822db677ebb1e7 0t0 TCP *:sun-sr-https (LISTEN)

The socket connection to localhost failed..ErrorCode: 10061

When I type localhost on my browser , I am unable to successfully connect..I am getting
The socket connection to localhost failed.
ErrorCode: 10061.
No connection could be made because the target machine actively refused it 127.0.0.1:80
How can I fix it?
You start a web server on your localhost listening on port 80. At present there isn't one.

SSH Tunnelling - Remote Debugging

I can ssh into the server say abc.xyz on port 22 but i can't remote debug it in Eclipse. Here is the additional info :
Server startup arguments -
-Xdebug -Xrunjdwp:transport=dt_socket,address=1234,server=y,suspend=n
Confirmation from logs -
Listening for transport dt_socket at address: 1234
When I telnet on my local system -
local-machine% telnet abc-xyz 1234
Trying xx.xx.xx.xx...
telnet: connect to address xx.xx.xx.xx: Connection timed out
telnet: Unable to connect to remote host: Connection timed out
When I telnet on the server(abc.xyz) -
abc-xyz% telnet localhost 1234
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Connection closed by foreign host.
I've tried setting up tunnel via -
ssh -L 1234:localhost:1234 user#abc-xyz
ssh -L 1234:127.0.0.1:1234 user#abc-xyz
I'm attaching debugger in Eclipse with this config -
Connection type - Standard (Socket attach)
Host - localhost
Port - 1234
Can't get Eclipse to attach to 1234.
After setting up SSH Tunnel, if i manually try to connect to the port, i get this response -
local-machine% telnet localhost 1234
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Connection closed by foreign host.
and I see an entry in catalina.out as:
channel 4: open failed: connect failed: Connection refused
Any help would be appreciated.
EDIT - 1:
I ran
abc-xyz% ~#
and got the following output:
The following connections are open:
#2 client-session (t4 r0 i0/0 o0/0 fd 7/8 cc -1)
#3 direct-tcpip: listening port 1234 for localhost port 1234, connect from 127.0.0.1 port 23456 (t4 r1 i0/0 o0/0 fd 10/10 cc -1)
I think ssh tunneling is working, it's just the way i'm connecting with Eclipse which is going wrong here.
I just had to increase timeout. (Can be done via Window->Preferences->Java->Debugging. Set it to some appropriate value.)

Get this result back when putting `postgres -D /usr/local/var/postgres` in terminal

When I put postgres -D /usr/local/var/postgres in terminal I get this back:
LOG: could not translate host name "localhost", service "5432" to address: nodename nor servname provided, or not known
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets`
Can someone help me fix this?
Check your /etc/hosts file for missing line:
127.0.0.1 localhost.localdomain localhost
Regards
H