I've got two EC2 instances and I'm trying to see if I can ssh from one to another.
If I try from my Windows instance to PuTTY each of them it works( by providing the .ppk file).
Now, both instances were associated to the same key-pair and if I chekc in the .ssh/authorized_keys there is the same public key(obviously because it refers to the same Key-pair that I generated in AWS).
I tried to ssh <other host> but it asks me for a passphrase of the key which doesn't exist.
SO what I did now is to create a key-pair from instance A with ssh-keygen, then I tried
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
but it gives me this error:
Permission denied (publickey).
Please if you have any ideas they are welcome.
You can't use ssh-copy-id if the only authentication method you have is publickey.
When you generated the key on the first instance, you need to copy public part from ~/.ssh/id_rsa.pub to the other instances ~/.ssh/authorized_keys.
Related
I have three servers A,B, and C. I need to do is to run something like:
my_self#A:~$ ssh B "ssh C run_a_script_here"
This works if I have my ssh keys setup correctly on A,B,C, and I do not use SSH passphrase. But if I run this as a different user who has a SSH passphrase, I got an error:
user_has_passphrase#A:~$ ssh B "ssh C run_a_script_here"
Pseudo-terminal will not be allocated because stdin is not a terminal.
user_has_passphrase#A: Permission denied (publickey).
I checked online and it looks like this is a ssh-agent and/or keychain setup issue, and I have no idea how to set it up as I never used passphrase with my ssh keys.
Thanks,
Philip
You don't need to copy your private key on host-B and host-C.
Normally, you only add the public key to .ssh/authorized_keys and host-b and host-c.
Then you can use a proxy jump:
ssh hostC -o ProxyJump=hostB
You will be asked only once for your passphrase (on host-A)
I am trying to configure a SSH Key-Based Authentication and after i created one, i want to copy the SSH Public Key to my server. When i give the following command on git bash : ssh-copy-id username#remote_host , i am asked for a password.
remote_host must be the floating_ip of the VM that i am trying to connect to ?
Which password should i type in ?
It would be really helpful if you could answer my questions.
On the first SSH operation (here an ssh-copy-id), you would need the password of the remote account, in order for the command to add your public kay to said remote user account ~/.ssh/authorized_keys.
Only then subsequent SSH commands would work without asking for password (only passphrase, if your private key is passphrase-protected, and if you have not added the private key to an ssh agent, for caching said passphrase).
I am given with id_rsa.pub from client. And I was told to connect to it. I tried adding the key with ssh-copy-id user#ec2-remoteserver.com
But it gave the error. Permission denied (publickey).
Then I thought of trying to connect with
ssh -i /c/Users/kdash/Desktop/id_rsa.pub user#ec2-instance.com
It now says the error
Load key "/c/Users/kdash/Desktop/id_rsa.pub": invalid format
Can anyone please help me understand how shall I add the given .pub key file and access to the remote server.
Earlier I had connected to servers with .pem files as such:
ssh -i /c/Users/kdash/Desktop/server.pem user#ec2-instance.com
I am not clear how .pub file can be used.
Client should provide you the private key to connect to server.
I am sure client must have added the public key in their ~/.ssh/authorized_keys
Once client provide you the private-key file, then you can connect as
ssh -i <private-key> user#ec2-instance.com
See example here, remote machine is adding public key in ~/.ssh/authorized_keys and then user can connect to it using private key.
So I guess, you need private key file to connect to remote ssh server.
Remote machine should never add private key in ~/.ssh/authorized_keys.
I need to establish SSH connection between 2 AMI Ec2 instances.
I have tried by generating new key pair with ssh-keygen method.
Even after copying public key id_rsa.pub from one instance to authorized_keys folder in another instance, I'm facing
"Permission denied (publickey)" error.
I feel I might have missed some simple step in this process.
Please provide steps to be followed in establishing ssh connection between two AMI EC2 instances by generating new key pair using ssh-keygen?
authoried_keys is not a folder, it is a file. Create the file: ~/.ssh/authorized_keys and copy the contents of the public key in the other machine. Once copied, ensure that security groups allow the ports.
My problem is that one user forgot his ssh passphrase for key, so i had to generate new one and install it on all environments.
Here's the thing: I have created key without any passphrase and copied it to all servers (single key pair on all servers) so every server has the same id_rsa key and id_rsa.pub key added to authorized_keys. And the problem is I still can't login to these servers.
output:
user#server1:~$ ssh user#server2
Enter passphrase for key '/home/user/.ssh/id_rsa': <empty>
Permission denied (publickey).
user#server1:~$
I have no idea what may cause the problem. I have generated those keys twice, tried to use ssh-add command to be sure that system can see those keys but nothing helped.
Do you have any idea how to solve this problem?
Remove ".ssh" forlder in every user folder (e.g. /home/user1), then try to generate new keys again. ".ssh" folder is hidden by default, press CTRL + H to showing the hidden file and folders.
Also, you can ssh to a system as password-less :
ssh-keygen
ssh-copy-id user#host
After the key is copied, ssh into the machine is password-less :
ssh user#host
After change your key, type:
ssh-add
And to verify, type:
ssh-add -l
And verify with md5sum your id_rsa.pub in your host and authorized_keys on the server.