redis client not connecting - ssh

when i am trying to connect to redis client db using a public key, by use of following command,
ssh -i somekey.pem -v -L 6379 : 127.0.0.1 user#domain.com
when i do so its not connecting and giving the following error
OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
Bad local forwarding specification '6379'
there is no other redis instance running
what is the issue and what should i do to solve the issue

well i solved this
i did not put port number(6379) after host(127.0.0.1)
following command is working now
ssh -i somekey.pem -v -L 6379:127.0.0.1:6379 user#domain.com

Related

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.

glassfish4 create-node-ssh failed due to ssh key exchange not finished

I'm trying to create a node on a remote host(I've already created a domain).
I'm running the command:
asadmin -p <port_number> create-node-ssh --nodehost <remote_hostname> --installdir <glassfish_installed_dir_path> <node_name>
and getting the following error everytime:
remote failure: Warning: some parameters appear to be invalid.
SSH node not created. To force creation of the node with these parameters rerun the command using the --force option.
Could not connect to host <hostname> using SSH.
There was a problem while connecting to <hostname>:22
Key exchange was not finished, connection is closed.
Command create-node-ssh failed.
From the error it seems that there is some connection problem. But I can ssh to the target server and I'm using the same key_pair.
After searching for some solution (link1, link2) I found that trying to login through ssh without password could solve this.
But no luck. Now I can ssh to & from the target server without password as well. But this issue is still there.
What should I check for, in order to resolve this ?
Let me know if I'm missing out anything.
Can you try to start sshd daemon in debug mode to a different port at the remote node host:
sudo sshd -D -d -e -p 23
and try create-node-ssh command against that ssh port?:
asadmin -p <port_number> create-node-ssh --nodehost <remote_hostname> --installdir <glassfish_installed_dir_path> --sshport 23 <node_name>
I had an issue regarding glassfish ssh exchange keys because of ssh newer versions deprecating older algorithms:
Unable to negotiate with X.X.X.X port XXXXX: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 [preauth]
My solution was to add legacy keys to /etc/ssh/sshd_config:
KexAlgorithms +diffie-hellman-group1-sha1
Ciphers +aes128-cbc
Even if this is not your case, sshd debug will surelly give you more information.

openshift ssh access denied

If I try to ssh or git push to openshift, I get the error "access not allowed". The SSH public key is listed on openshift and matches the key in ~/.ssh/id_rsa.pub Linux Mint 17.
dick#dick1 ~ $ ssh-keygen -l
Enter file in which the key is (/home/dick/.ssh/id_rsa):
2048 70:f1:92:9d:d8:7b:09:4c:8e:7d:60:94:53:a0:7a:8a OpenShift-Key (RSA)
dick#dick1 ~ $ rhc sshkey list
default (type: ssh-rsa)
-----------------------
Fingerprint: 70:f1:92:9d:d8:7b:09:4c:8e:7d:60:94:53:a0:7a:8a
Available: true
You have 1 SSH keys associated with your account.
dick#dick1 ~ $ cd /c/src/time
dick#dick1 /c/src/time $ git push
ssh: connect to host time-cronos.rhcloud.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
dick#dick1 /c/src/time $ ssh time-cronos.rhcloud.com
ssh: connect to host time-cronos.rhcloud.com port 22: Connection timed out
dick#dick1 /c/src/time $
Sounds like maybe port 22 is blocked where you are? Can you telnet to port 22 at time-cronos.rhcloud.com? If not it might be time to involve your systems administrator or try from another location.
It seems that port 22 is blocked as the connection times out, I would suggest running an nmap scan in order to get more information regarding the port state provided that you have permission to port scan the server:
nmap -p 22 --reason -sT time-cronos.rhcloud.com

SSH Server in Cygwin - Windows 7

I created a ssh server in cygwin using the commands:
mkpasswd -l /etc/passwd
mkgroup -l /etc/group
ssh-host-config -y
After that, I'm trying to connect the server but it closes my connection with the following message:
$ ssh cyg_server#localhost
cyg_server#localhost's password:
Last login: Thu Jul 18 16:16:53 2013 from ::1
Connection to localhost closed.
Why it is happening? How do I fix it?
Note: Firewall - off
Thanks =)
Do you have permission to connect in the machine that you've created the server?

gitlab 5.2 can clone and push by http, but can't clone or push by ssh

I have setup my gitlab server behind a route, and I have mapped my ssh port to 50000 in the server. the gitlab port is 50001.Then I create a test project and try to clone it in another machine,it's ok when I use http.
git remote add origin http://myrouteaddress:50001/user/test.git
but when I try to test it use ssh, it failed with
git remote add origin ssh://git#myrouteaddress:50000/user/test.git
fatal: The remote end hung up unexpectedly
I have test my ssh setting with
ssh -vT git#myrouteaddress -p 50000
and it passed without problem.
I find out the auth with
sudo tail -f /var/log/auth.log
and get the follow
Jun 1 12:29:22 debian sshd[24799]: Accepted publickey for git from mytestpcip port 37848 ssh2
Jun 1 12:29:22 debian sshd[24799]: pam_unix(sshd:session): session opened for user git by (uid=0)
Jun 1 12:29:22 debian sshd[24801]: Received disconnect from mytestpcip: 11: disconnected by user
Jun 1 12:29:22 debian sshd[24799]: pam_unix(sshd:session): session closed for user git
can someone tell me the reason? Thank you very much!
I finally got the reason, I have generate the ssh rsa key with wrong parameter. the right way is:
ssh-keygen -t rsa -C "email#email.com"
Check your config:
# check gitlab-shell install
sudo -u git -H /home/git/gitlab-shell/bin/check
# check gitlab install
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Then, try and use the scp syntax:
git#myrouteaddress:50000:user/test.git
or
gitolite:user/test.git
With a config file in your ~/.ssh/config with
Host gitolite
Hostname myrootaddress # or ip address
Port 5000
User git
IdentityFile ~/.ssh/git