ssh connection to git failing - ruby-on-rails

I am opening some question I somewhat asked before but now the problem seems to be pretty linked to ssh.
I have installed Gitlab in /home/myuser/gitlab.
I created a rep test
Following instructions, I added a remote git#localhost:root/testing.git (Gitlab's server runs on port 3000)
Now, when I try to push, I get this error message:
$ git push -u origin master
ssh: Could not resolve hostname mylocalhost: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Now, I found that there was a problem with my ssh connect. Here's my /home/myhome/.ssh/config file
Host mylocalhost
Hostname localhost
PORT 3000
User git
IdentityFile /home/myuser/.ssh/id_rsa.pub
When I run ssh mylocalhost I get this message
ssh_exchange_identification: Connection closed by remote host
On verbose mode, it seems that the connection is established on the right port but the porcess fails here debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request.
I tried to update my /System/Library/LaunchDaemons/ssh.plist (I am using OSX) to forward port listening to 3000 but then the Gitlab Webrick Rails server won't run anymore. L tried to change git remote set-url origin mylocalhost:testing.git

Gitlab's HTTP interface is probably running on port 3000, but SSH isn't running there to push the repository to.
The message of ssh: connect to host localhost port 22: Connection refused means that the SSH client was unable to connect to the SSH server at localhost on port 22. I'd ensure you've installed gitlab correctly and Gitlab is running correctly. Also ensuring the ssh server is running and able to accept connections on port 22.

You cannot hope to use the port 3000 if you are using a fully specified url
git#localhost:root/testing.git
As I have explained to you before:
The idea of the ssh config file is to define an entry "foobar" which will set the right server name (Hostname), ssh private key (IdentityFile), and user under which the ssh session is opened.
That would allow to do 'ssh foobar' (without having to put git#xxx, and with non-standard public/private keys files).
You can define as many entry as you want, allowing you to use different user and keys.
So you cannot define origin with git#xxx. You must type:
git remote add origin mylocalhost:testing.git
Or, if origin is already defined, and you need to change its url:
git remote set-url origin mylocalhost:testing.git
(no 'root/' you don't specify any path in front of a gitlab repo: gitlab will deduce the full path of the repo)
But you need to be sure your sshd starts on port 3000, and that gitlab.yml contains that port number.
ssh: Could not resolve hostname mylocalhost: nodename nor servname provided, or not known
That means ssh cannot find ~/.ssh/config, with a mylocalhost entry in it.
Make sure that file exist.
Your previous question put in ~/.git/config, which has nothing to do with ssh.

At last, I figured out what was the problem. I had to set properly the ~/.ssh/config file
Host mylocalhost
Hostname localhost
//I deleted a line specifying the PORT to 3000
User git
IdentityFile /home/myuser/.ssh/id_rsa //It was previously set to /home/myuser/.ssh/id_rsa.pub
Then I reinstalled a key but I still got some problem. Finally, setting the perm of the file /home/myuser/.ssh/id_rsa to 644 and it worked just fine. For information, I found searching in the web that some settings could work with a 700 or a 600 chmod perm, but for me 644 did the trick

Related

GitLab can't reach PlantUml in docker container

So I have GitLab EE server (Omnibus) installed and set up on Ubuntu 20.04.
Next, following official documentation found on GitLab PlantUML integration, I started PlantUML in a docker container which I did with the following command:
docker run -d --name plantuml -p 8084:8080 plantuml/plantuml-server:tomcat
Next, I also configured /etc/gitlab/gitlab.rb file and added next line for redirection as my GitLab server is using SSL:
nginx['custom_gitlab_server_config'] = "location /-/plantuml/ { \n proxy_cache off; \n proxy_pass http://plantuml:8080/; \n}\n"
In the GitLab server GUI in admin panel, in Settings -> General, when I expand PlantUML, I set the value of PlantUML URL to (two ways):
1st approach:
https://HOSTNAME:8084/-/plantuml
Then, when trying to reach it through the browser through this address(https://HOSTNAME:8084/-/plantuml), I get
This site can’t provide a secure connection.
HOSTNAME sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
2nd approach:
Also I tried to put before that I tried different value in in Settings -> General -> PlantUML -> PlantUML URL:
https://HOSTNAME/-/plantuml
Then, when trying to reach it through the browser through this address (https://HOSTNAME/-/plantuml), I get
502
Whoops, GitLab is taking too much time to respond
In both cases when I trace logs with gitlab-ctl tail I get the same errors:
[crit] *901 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: CLIENT_IP, server: 0.0.0.0:443
[error] 1123593#0: *4 connect() failed (113: No route to host) while connecting to upstream
My question is which of the above two ways is correct to access PlantUML with the above configuration and is there any configuration I am missing?
I believe the issue is that you are running the plantuml in a docker container and then trying to reach it via gitlab (on localhost) with name.
In order to check if that is the issue please change
proxy_pass http://plantuml:8080/
to
proxy_pass http://localhost:8080/
and trying again with the first approach.
Your second approach seems to be missing the container port in the url.

I got an error when I try to connect my docker via HTTPs: x509: certificate is valid for 0.0.0.0, not <My Container IP>

My dockerd(docker daemon) running on my remote computer instance.
I need connect my dockerd with my local computer, and I try This Link
when I finished, I got an error.
docker --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H=$HOST:2376 ps
error during connect: Get https://$HOST:2376/v1.24/containers/json: x509: certificate is valid for 0.0.0.0, not $HOST
What should I do?
Update:
$HOST is my remote server IP address.
Did you follow this from the link you mentioned?
Since TLS connections can be made through IP address as well as DNS name, the IP addresses need to be specified when creating the certificate. For example, to allow connections using 10.10.10.20 and 127.0.0.1:
$ echo subjectAltName = DNS:$HOST,IP:10.10.10.20,IP:127.0.0.1 >> extfile.cnf
Could it be that your real value (instead of the $HOST in your snippet) was not used in the aforementioned step?

Vagrant cant connect to local host

Hello i am having trouble with vagrant setup.
So i am trying to ping serverless API which runs on http://localhost:3000/ (and it's outside vagrant project).
Right now my vagrant project runs on https://localhost:4443/.
Overall trying to CURL request from vagrant project to another serverless project.
Tried to use http://localhost:3000/ in CURL request but getting Failed to connect to localhost port 3000: Connection refused
Tried to use VM ip 10.0.2.15 address same
Tried to do port forwarding in vagrantfile config.vm.network :forwarded_port, guest: 3000, host: 3000 and use machine IP address 192.168.0.16, getting empty response from server, when i try to do telnet 192.168.0.16 3000 getting
Trying 192.168.0.16...
Connected to 192.168.0.16.
Escape character is '^]'.
Connection closed by foreign host.
Any idea what to try?
I had to use VM IP address something like
curl -X GET http://10.0.2.2:3000
These errors may be caused due to follow reasons, ensure the following steps are followed. To connect the local host with the local virtual machine(host). Here, I'am connecting http://localhost:3001/ to the http://abc.test Steps to be followed:
1.We have to allow CORS, placing Access-Control-Allow-Origin: in header of request may not work. Install a google extension which enables a CORS request.*
2.Make sure the credentials you provide in the request are valid.
3.Make sure the vagrant has been provisioned. Try vagrant up --provision this make the localhost connect to db of the homestead.
Try changing the content type of the header. header:{ 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8;application/json' }
this point is very important.

Failed to connect to bitbucket.org port 443: Network is unreachable

Iam getting the following issue while trying to clone the repository.
fatal: unable to access 'https://Tejaswikatha#bitbucket.org/activecubs_angularjs/activecubs-admin-angularjs.git/': Failed to connect to bitbucket.org port 443: Network is unreachable
For UBUNTU:
Open /etc/hosts file
Add 104.192.143.3 bitbucket.org as a first line and save file
Now cloning will work.
This may be caused by known issues trying to git push, pull, clone over IPv6.
You can force IPv4 by adding the following line to your hosts file (/etc/hosts on Linux, c:\windows\System32\drivers\etc\hosts on Windows):
104.192.143.1 bitbucket.org
In you have a newer git client (>2.8), you can also force IPv4 via the -4 or --ipv4 switch.

Neo4j remote shell through vagrant issue

I'm running a Neo4j instance inside my Vagrant machine. I put these lines into neo4j.properties to start the server with the remote shell
remote_shell_enabled=true
remote_shell_host=0.0.0.0
remote_shell_port=1337
I start neo4j server with the command bin/neo4j start
After that, I use neo4j shell inside vagrant to connect to the remote shell and it works fine.
I forward the port 1337 to the host machine with this in the Vagrantfile
config.vm.network :forwarded_port, guest: 1337, host: 9255
And then on my host machine (MacOS), I use the neo4j shell to connect to that server but I fail
$ bin/neo4j-shell -port 9255 -v
Unable to find any JVMs matching version "1.7".
ERROR (-v for expanded information):
Connection refused
java.rmi.ConnectException: Connection refused to host: 10.0.2.15; nested exception is:
java.net.ConnectException: Operation timed out
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
at com.sun.proxy.$Proxy1.welcome(Unknown Source)
at org.neo4j.shell.impl.AbstractClient.sayHi(AbstractClient.java:254)
at org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:70)
at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:62)
at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:45)
at org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:178)
at org.neo4j.shell.StartClient.startRemote(StartClient.java:302)
at org.neo4j.shell.StartClient.start(StartClient.java:179)
at org.neo4j.shell.StartClient.main(StartClient.java:124)
Caused by: java.net.ConnectException: Operation timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 14 more
The vagrant machine has no firewall and I'm still able to connect to the web interface
UPDATE
Holy ###**(* I got it working after 6+ hours! With default configuration Neo4j only accepts local connections. I'm not a networking wiz, but apparently neo4j could tell that port forwarded connections are non-local, and refused them. To fix, you need to configure your neo4j.conf file to accept non-local connections
# To accept non-local connections, uncomment this line:
dbms.connectors.default_listen_address=0.0.0.0
# You also need to remove the 'advertised_address' from each connector,
# so that only the port is specified
# i.e. my conf file originally had dbms.connector.bolt.listen_address=localhost:7472
# I changed it to dbms.connector.bolt.listen_address=:7472
# Bolt connector
dbms.connector.bolt.enabled=true
dbms.connector.bolt.listen_address=:7472
# HTTP Connector. There must be exactly one HTTP connector.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474
# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=false
dbms.connector.https.listen_address=:7473
Of course, in addition to all of this you need to have port forwarding properly set up in your vagrantfile. Strangely, I found I needed to make sure I was sharing every port neo4j was broadcasting on (http, https, bolt) or else there were some intermittent connection issues with the web console. This all being said, I can now properly connect via neo4j-shell, cypher-shell, and the web console--all from my host machine.
Original
I'm running into a similar problem. In your case, the output error includes Unable to find any JVMs matching version "1.7". The bin/neo4j-shell file is written in Java, I believe (or perhaps the shell it starts relies on Java). The host machine needs to have the java development kit (JDK) installed to run that command. Try installing the JDK and running it again.
This all being said, I DO have the JDK installed on my machine (now "1.8") and I'm running into a similar problem when I try and run bin/cypher-shell (which has replaced bin/neo4j-shell) from my host machine (a mac): Unable to connect to localhost:7687, ensure the database is running and that there is a working network connection to it. When I try and connect from within vagrant, I do not run into any errors. My vagrantfile contains config.vm.network "forwarded_port", guest: 7687, host: 7687, host_ip: "127.0.0.1".
I'll also note that, while I can connect to the neo4j web interface within vagrant, I cannot connect to the web interface on my host machine (i.e. port forwarding doesn't seem to be working for anything neo4j related). I can connect to a rails app running within the same vagrant box from my host machine just fine, however. While I haven't tried it, I imagine I can indirectly access the neo4j database through my Rails app (since my Rails app is port forwarding correctly).
Still I cannot fix this problem, but I find another work around so I will post it here. We can use an ssh tunnel to pretend that we are connecting to localhost from that server. Use ssh to execute the command directly from the remote host
ssh user#host /path/to/neo4j-shell
or if you are using vagrant
vagrant ssh -c '/path/to/neo4j-shell'

Resources