Unable to establish SSH connection between two AMI ec2 instances

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Trying to establish ssh connection between two ec2 instances. Copied Host A id_rsa.pub key to Host B's authorized_keys file



[root@ip-172-31-9-173 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


[root@ip-172-31-11-205 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


Error:



[root@ip-172-31-9-173 ~]# ssh root@172.31.11.205
Permission denied (publickey).


Not sure what is missing here.










share|improve this question























  • Can you actually ssh by providing the username and password? If not, then if you can access the file ensure you have an AllowUsers entry in /etc/ssh/sshd_config and also that you are allowing SSH access to the subnet at the top of that file. if you do amend the sshd_config remember to restart the SSH service.
    – l0ckm4
    Aug 13 at 12:32















up vote
0
down vote

favorite












Trying to establish ssh connection between two ec2 instances. Copied Host A id_rsa.pub key to Host B's authorized_keys file



[root@ip-172-31-9-173 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


[root@ip-172-31-11-205 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


Error:



[root@ip-172-31-9-173 ~]# ssh root@172.31.11.205
Permission denied (publickey).


Not sure what is missing here.










share|improve this question























  • Can you actually ssh by providing the username and password? If not, then if you can access the file ensure you have an AllowUsers entry in /etc/ssh/sshd_config and also that you are allowing SSH access to the subnet at the top of that file. if you do amend the sshd_config remember to restart the SSH service.
    – l0ckm4
    Aug 13 at 12:32













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Trying to establish ssh connection between two ec2 instances. Copied Host A id_rsa.pub key to Host B's authorized_keys file



[root@ip-172-31-9-173 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


[root@ip-172-31-11-205 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


Error:



[root@ip-172-31-9-173 ~]# ssh root@172.31.11.205
Permission denied (publickey).


Not sure what is missing here.










share|improve this question















Trying to establish ssh connection between two ec2 instances. Copied Host A id_rsa.pub key to Host B's authorized_keys file



[root@ip-172-31-9-173 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


[root@ip-172-31-11-205 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTTRSTwBClsq7/punxLQvq00Ba7iMZRbQKAQhC+GVuQFB2LfWk9Hsetu4CqHoGo4R4BJ/SW/4v+AfKlmQ/kA8WrQ12R0dR9cuhEbbnltMXSauwrsndIf4egJVzJs3BM12jXEx+E6wSlK8nUu3xpmY12WUkJOAWfWJ6rnE4XArIcmtNzfpJyZgFhNv2fKYRBTCgU0l4HLo2uIiQj8/aLT2gQeRUdARNn3QLBrITMN6rojo1vmWYnXhjWxeUoYVDj5+bsrqfbAtyzPm43WS+2RZ0T1Rr50+REl+jin0y108v04me7BluidN013oj+gLI73A86/qBgo08l5RwG2p+oOzf root@ip-172-31-9-173


Error:



[root@ip-172-31-9-173 ~]# ssh root@172.31.11.205
Permission denied (publickey).


Not sure what is missing here.







ssh amazon-ec2 aws






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 13 at 8:12

























asked Aug 13 at 8:04









Su_scriptingbee

3817




3817











  • Can you actually ssh by providing the username and password? If not, then if you can access the file ensure you have an AllowUsers entry in /etc/ssh/sshd_config and also that you are allowing SSH access to the subnet at the top of that file. if you do amend the sshd_config remember to restart the SSH service.
    – l0ckm4
    Aug 13 at 12:32

















  • Can you actually ssh by providing the username and password? If not, then if you can access the file ensure you have an AllowUsers entry in /etc/ssh/sshd_config and also that you are allowing SSH access to the subnet at the top of that file. if you do amend the sshd_config remember to restart the SSH service.
    – l0ckm4
    Aug 13 at 12:32
















Can you actually ssh by providing the username and password? If not, then if you can access the file ensure you have an AllowUsers entry in /etc/ssh/sshd_config and also that you are allowing SSH access to the subnet at the top of that file. if you do amend the sshd_config remember to restart the SSH service.
– l0ckm4
Aug 13 at 12:32





Can you actually ssh by providing the username and password? If not, then if you can access the file ensure you have an AllowUsers entry in /etc/ssh/sshd_config and also that you are allowing SSH access to the subnet at the top of that file. if you do amend the sshd_config remember to restart the SSH service.
– l0ckm4
Aug 13 at 12:32











1 Answer
1






active

oldest

votes

















up vote
0
down vote













You are missing the private key id_rsa in the machine initiating the connection to the 2nd machine.



Place it on /root/.ssh/id_rsa if doing it as root. Also do not forget that SSH is picky about rights, so you have to do:



chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa


On the long term, consider not working as root, and using a regular user.






share|improve this answer




















  • It's not working with those permissions too.
    – Su_scriptingbee
    Aug 17 at 7:54










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462235%2funable-to-establish-ssh-connection-between-two-ami-ec2-instances%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You are missing the private key id_rsa in the machine initiating the connection to the 2nd machine.



Place it on /root/.ssh/id_rsa if doing it as root. Also do not forget that SSH is picky about rights, so you have to do:



chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa


On the long term, consider not working as root, and using a regular user.






share|improve this answer




















  • It's not working with those permissions too.
    – Su_scriptingbee
    Aug 17 at 7:54














up vote
0
down vote













You are missing the private key id_rsa in the machine initiating the connection to the 2nd machine.



Place it on /root/.ssh/id_rsa if doing it as root. Also do not forget that SSH is picky about rights, so you have to do:



chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa


On the long term, consider not working as root, and using a regular user.






share|improve this answer




















  • It's not working with those permissions too.
    – Su_scriptingbee
    Aug 17 at 7:54












up vote
0
down vote










up vote
0
down vote









You are missing the private key id_rsa in the machine initiating the connection to the 2nd machine.



Place it on /root/.ssh/id_rsa if doing it as root. Also do not forget that SSH is picky about rights, so you have to do:



chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa


On the long term, consider not working as root, and using a regular user.






share|improve this answer












You are missing the private key id_rsa in the machine initiating the connection to the 2nd machine.



Place it on /root/.ssh/id_rsa if doing it as root. Also do not forget that SSH is picky about rights, so you have to do:



chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_rsa


On the long term, consider not working as root, and using a regular user.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 13 at 12:44









Rui F Ribeiro

36.6k1271116




36.6k1271116











  • It's not working with those permissions too.
    – Su_scriptingbee
    Aug 17 at 7:54
















  • It's not working with those permissions too.
    – Su_scriptingbee
    Aug 17 at 7:54















It's not working with those permissions too.
– Su_scriptingbee
Aug 17 at 7:54




It's not working with those permissions too.
– Su_scriptingbee
Aug 17 at 7:54

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462235%2funable-to-establish-ssh-connection-between-two-ami-ec2-instances%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)