Prompted for password by ssh when trying to connect to Amazon EC2 instance - ssh

I've followed a couple of tutorials for creating an Amazon EC2 instance using the command line tools
http://www.zabada.com/tutorials/deploying-a-rails-application-to-production-on-amazon-ec2.php
http://www.smartfrog.org/wiki/display/sf/Starting+an+EC2+Image+by+Hand
and all is well, i
ec2-add-keypair (directing the output of ec2-add-keypair directly to a file in ~/.ssh)
chmod 600 the keypair
ec2-run-instance
ec2-describe-instances
then, when the new instance is running try to ssh on
ssh -i ~/.ssh/ec2-keypair ec2-user#foo.bar.amazon.com
At this point i'm ALWAYS prompted for a password. Obviously there's no password so it always refuses me access.
My question is, what am i doing wrong here? Why am i being prompted for a password and how can i put this right so i can ssh onto the machine i've just started?
I'm guessing this is something to do with my local setup, but as far as i know this machine hasn't had anything custom done with .ssh (there's certainly no config file or anything like that lying around that might be screwing with things).
Anyone have any ideas or suggestions?

ec2-user# ? Why not root# ?

Related

How can I change the port for Webmin access?

I'm managing a Rails website that relies on MySQL tables. I used to be able to access the tables with Webmin by going to xxx.xxx.xxx.xxx:10000 . At some point, I lost the ability to access it this way.
I'm not great with SSH, but I was able to SSH into my website as a general user. Then, I switched to Root user. Then, I ran this command to restart my Webmin:
svcadm restart webmin
It seemed to accept the command, but I'm not really sure how to check. Anyway, I started getting a new error message when I tried to access Webmin through my browser:
ERR_SSL_VERSION_OR_CIPHER_MISMATCH
The website uses a connection with Cloudflare. My guess was that this could be the problem since Cloudflare doesn’t support port 10000. I tried deactivating Cloudflare, but it didn't resolve the problem.
Still, I figured I might need to use SSH to change the port for Webmin access just in case. I found a source that suggested how to do it, and it starts with SSH. I went in through SSH and I switched to Root user. Then, I ran this command:
/etc/webmin/miniserv.conf
And it tells me
bash /etc/webmin/miniserv.conf Permission denied
How can I get past this step? Am I headed the wrong direction to get access back to Webmin? Thank you!

Connect to Windows server with ssh with keys

I would like to connect to a Windows server via SSH with private and public key from my local Windows machine.
The problem is that I can not figure out how and am asked to enter the password every time.
Eventually I want to setup remote coding with vs code but as the ssh program faces the same problem as in VS code I think we can leave VS code out of the picture.
Generally the connection to the server is working. So if I type ssh {myuser}#{servername} I am prompted to write my password and afterwards the console is connected to the server.
Now I would like to set it up in a way that I do not need to write my password every time, there for I setup public and private key following this tutorial.
But the system still ask my for a password each time. Does anyone know what the problem might be?
I would guess that the permissions might be an issues. In the link listed above they mentioned that I should set the permissions to 700 for the .ssh folder and 640 for the authorized_keys file. As Windows does not hove the chmod command (or at least it does not seem to change the permissions) this could be the problem.
I have also put the public key in the authorized_keys file of the .ssh folder of the user I am using.
Also as the copying with cat and | did not work I moved the files there manually but otherwise is sticked to the tutorial.
Does anyone know what the issue is?
Furthermore I managed to connect both the server and the client to a bit bucket server using ssh key with out a problem.

Script to ssh to remote server and overwrite file

Been toying around with my Raspberry Pi running raspbian.
I'd like to update a webpage with a shell script that requires no input, such as password.
I just tried creating the keys and putting them in the .ssh file on the remote server, but when I run my simple shell script of ssh user#domain.net 'ls' and it still prompts me for a password.
I also looked into paramiko slightly, but didn't get very far with it.
All I need is to update/replace an html file with text/information that I have.
Thanks
I think your Public/Private Keys for Authentication is not configured correctly in your server.
Can you check this link which explains the authentication step:SSH Authentication

still asking for password even after setting up the machine for Password-less SSH Login

I need to copy a file from a remote machine to my local machine and I need to automate it.
I've tried SCP command and it's working, however, I could not automate the part wherein it is asking for the password of the user of the local machine and the remote machine.
Based on this article I can Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
after following all the instructions written there, I tried to access the remote machine using this
ssh lalala#XXX.XXX.XXX.XXX
it works, it doesnt ask for the password anymore. But when I tried copying a file from that machine using the command below,
scp lalala#XXX.XXX.XXX.XXX:'/a/b/c.txt' lelele#XXX.XXX.XXX.YYY:'/b/c/'
it still asks for the password of the localmachine which is the lelele#XXX.XXX.XXX.YYY
I wonder if I did something wrong? what could it be? is there something wrong with the format of the command?
BTW, im using Centos, and I'm planning to code it using python
If you are copying to your local machine why don't you just do
scp lalala#XXX.XXX.XXX.XXX:'/a/b/c.txt' /b/c/
?
I tried your line on some machine with similar setup and didn't get asked for password; I got an error instead, but this is probably due to differences in our configurations. I tried mine and it worked.
Regarding whether your connection succeeds in the remote machine you could tail this file there:
tail -f /var/log/secure
If you see no error there you can be sure (well, never say always) your layout with the generated keys is working.
In this case I bet you'll see no error there
I think you may have multiple ssh keys and set identies only as yes. If so, please check this answer: https://askubuntu.com/a/999306/398861

ssh permission denied (publickey) when trying to access ec2 from different computer

I am trying to access an ec2 instance using a different (mac) computer. In order to do so, I created a new keypair, used chmod 600 to set the permission, and then used ssh-add. When I try to ssh into my ec2 instance, I get "permission denied (publickey)". I'm sure my error is something idiotic and simple, but I can't seem to find it, can anyone help me out?
You need to ensure the ~/.ssh/id_rsa.pub (if it's an RSA key) from your Mac is appended to the ~/.ssh/authorized_keys file on the target machine. Normally, if this is a default Amazon API, the user is "ec2-user" -- ~ec2-user/.ssh/authorized_keys
REMEMBER TO APPEND and not remove other entries in that file -- else, you risk locking yourself out of that machine ...
is your private key on the new computer?
You need to put that on the computer you ssh in with. I usually keep mine on a flash drive.... I am not running linux atm so i forget the default directory it checks. Maybe this joggs your memory some. I think the directory would be like ~/.id_rsa/ or something?