how to make passwordless connections from IP1 to IP2? - ssh-keys

I had create authentication
" $ssh-keygen -t rsa "
create .ssh directory on 10.10.10.5
" $ssh root#10.10.10.5 mkdir -p.ssh "
upload generated public keys to - 10.10.10.5
" $cat.ssh/id_rsa.pub | ssh root#10.10.10.5'cat>>.ssh/autorized_keys' "
But i got this issue
-bash: cat.ssh/id_rsa.pub: No such file or directory
ssh: connect to host 10.10.10.5 port 22: Resource temporarily unavailabl

Suggesting to follow this article.
Works for me.
Maybe you suffer from missing file permission/access.

Related

ssh: Could not resolve hostname bitbucket.org: No such host is known

I am trying to add a ssh key to my bitbucket account. I followed the tutorial from https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/ (except that I generate an ed25519 key instead of rsa) and when I run
ssh -T git#bitbucket.org
it returns
ssh: Could not resolve hostname bitbucket.org: No such host is known.
I found that this should be solved by adding the host to the known_hosts file in .ssh folder, but I don't have this file generated.
I also use a vpn and I think this might be a problem, but I don't know how to solve this.

scp + error Name or service not known + custom port

I have read lot of post about this problem but i still can not solve it on my side.
I have a server i used to connect like this:
$ ssh user#xxx.xx.xx.xxx -p yy
user = is not root
xxx.xx.xx.xxx = ipv4 of my server
yy = custom port for ssh
Connexion works well.
I try to make a copy of a folder from my local machine (ubuntu) to the server(ubuntu 14.04) like this:
$ scp -r -p /home/user/my/folder/ ssh://user#xxx.xx.xx.xxx:yy/home/user/my/folder/on/server/
I get this error:
ssh: Could not resolve hostname ssh: Name or service not known
lost connection
I guess the connexion works well. So what could happen? A problem with rights of the folder?
For information, my local machine get both ipv4 and ipv6 address. Could it be that?
Thank you in advance for any help.
jb
Check manual page for scp. It describe the usage of scp with all the switches and options:
scp [...] [-P port] [[user#]host1:]file1 ... [[user#]host2:]file2
Your command should be:
$ scp -r -p -P yy /home/user/my/folder/ user#xxx.xx.xx.xxx:/home/user/my/folder/on/server/
Note port comes as -P yy, you don't write ssh:// in front the user and separate host from the remote path using colon (:).
You don't need "ssh://".
Here scp believes ssh is the name of the server you want to copy to. That's what the message says : "Could not resolve hostname ssh"
Try :
$ scp -r -p -P yy /home/user/my/folder/ user#xxx.xx.xx.xxx/home/user/my/folder/on/server/

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

Avoid to insert path of SSH key pair when connecting through passwordless login

I've set a passwordless connection through ssh using SSH key pair.
So if I run the command:
ssh -i /root/.ssh/root_master master#ip
I'm able to connect to master#ip without typing the pwd.
However I would like to connect without typing
-i /root/.ssh/root_master
but just typing
ssh master#ip
Can anyone help me?
localHost $ ssh remotePassword#remoteHostname
If you want to connect to remote server just by typing above command; you must create ssh trust between your local host and remote host.
Step 1: Create ssh setup on both the host. ( usually, .ssh directory is present at ~ directory )
Step 2: Generate RSA key pair on both the hosts. To generate RSA key pair
cd ~; mkdir -p .ssh; cd .ssh
ssh-keygen -t rsa -f "id_rsa" -N "\" -P "\"; chmod 400 id_rsa
touch authorized_keys; touch known_hosts
Step 3: Write id_rsa.pub file of local host to authorized_keys file of remote host and vice-versa (in case, you want to build both sides trust)
Step 4: Also make entry into known_hosts file or it will automatically create when you will connect for the first time.
This way you can create ssh trust between host and so make them passwordless.
Another way to do this is to usee new ssh module of perl.

SSH error in connection to a new Domain

I was already able to connect to the server via ssh properly. But recently after changing the server fixed-IP address and domain name, I cannot connect to the server by DNS name. Despite, I can ssh to the server with its IP address. The error of ssh with domain name is the following:
###########################################################
# WARNING: POSSIBLE DNS SPOOFING DETECTED! #
###########################################################
The DSA host key for example.com has changed,
and the key for the corresponding IP address X.X.X.X
has a different value. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /home/.ssh/known_hosts:10
remove with: ssh-keygen -f "/home/.ssh/known_hosts" -R X.X.X.X
###########################################################
# WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! #
###########################################################
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the DSA key sent by the remote host is
*:*:*:*:*:....
Please contact your system administrator.
Add correct host key in /home/.ssh/known_hosts to get rid of this message.
Offending DSA key in /home/.ssh/known_hosts:11
remove with: ssh-keygen -f "/home/.ssh/known_hosts" -R example.com
DSA host key for example.com has changed and you have requested strict checking.
Host key verification failed.
The answer is in the question:
ssh-keygen -f "/home/.ssh/known_hosts" -R example.com
You will get more info on the first google hit for the big message. WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
You should remove line 10 from your known_hosts because the system signalized you about the problem
Offending key for IP in /home/.ssh/known_hosts:10
I moved my ~/.ssh/known_hosts file and retried it worked. I guess the effect will just confirmation prompt for future connections, for the hosts that are there in known_hosts
I encountered the same problem.
I think the problem is that the item recorded in the "known-hosts" does not match something of the remote host(sorry, I don't know what the something is).
In my case, I just deleted the item in "known-hosts" according to the IP address of the remote host and ran ssh command again. Then it worked.
If you have got a backup of your /etc/ssh directory and want to restore it, just use
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user#hostname
for connecting once without checking.
Source: ssh man page
I faced same problem when I tried to do a pull.
Fix:
I deleted .ssh/known_hosts file on my system and retried pull, it worked.
Why this happened:
We had a gitlab migration. known_host file store gitlab ip, so it was not able to establish connectivity with existing host.
Just follow what is suggested.
sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ip
sudo ssh-keygen -f "/root/.ssh/known_hosts" -R host
These commands will remove old fingerprints, and then you will be asked:
The authenticity of host 'host (ip)' can't be established.
ECDSA key fingerprint is SHA256:YrD+1E4JmdeObwEyQW3zGqNhXE//64MMZrHHaInE7w0.
Are you sure you want to continue connecting (yes/no)?
Write "yes" and you will see such message:
Warning: Permanently added 'host,ip' (ECDSA)
to the list of known hosts.
This will create new fingerprint in the /root/.ssh/known_hosts file.
For me, it couldn't find the file so I had to flip the file path and domain name like so:
ssh-keygen -R example.com -f ~/.ssh/known_hosts
Just delete the known_hosts file
$ rm .ssh/known_hosts
$ ssh ras.mydomain.com
Try connecting with ssh again
ssh username#server-ip-here