标签:
Well, if it‘s ec2 or a digital ocean server, it would be a lot easier- you do what you normally do for a linux server.
Elastic Beanstalk(eb) is supposed to facilitate the deployment process.
but the setup/configuration is not that enjoyable, at least according to my experience (with Django)
Okay,
1. configure your security group, find the instance‘s group and add ssh and port 22 to the inbound tab, allow your IP since Amazon only whitelist ips.
2. create a key pair. It is weird to me that amazon create the .pem (priv+pub?) for you and according to some stackoverflow posts we need to -i this file when we connect to the server. That‘s not how it works normally, where we keep the private locally and let the server keep the public key, whenever we login we verify the key against each other.
3. need to enable the key-pair for your eb instance.
It supposed to be this simple. However i encoutered all kinds of weird problems.
First, the key pair doesn‘t seem to work, it kept on asking me for passphrase, which i never got a chance to specify from the amazon console. People say need to edit the file permission to 400 from 644, i was on a windows machine, cygwin doesn‘t seems to understand our company setting, chmod only added ‘everyone‘ and ‘domain‘ user to it. Tried to chmod from a mac and pasted in dropbox folder, of course, (i was being stupid) dropbox will change the permission cuz it‘s completely different file systems. The thing is the permission warning might not be the cause at all (Manually changed the windows security settings finally silienced this warning).
So after played around with different key pairs and tried to ssh in from a mac. I figured that changing the associated key-pair from the eb portal might simply not take effect at all (ssh -v hinted that server might not support this public key machanism). On another amazon doc i found that i might need to run eb ssh --setup to reconfigure the key-pair. It will actually rescale your instance: create a new one with the specified key and later on delete the old instance - that‘s how aws works.
This acutally helped. Notice that a new instance is using a differnt public URL, so be sure to get that new URL from the new instance.
It still kept on asking for passphrase, well, okay let me create my own key pair. Super easy on a mac, ssh-keygen, boom, got new keys, added my passphrase. Yes now that i have the passphrase, what say you? So i uploaded the public key to the aws portal.
(They eb ssh --setup again, waited for a couple of minutes)
Finally, now on my Mac:
ssh -i priv_key ec2-user@ec2-your-ip.compute-1.amazonaws.com
It works!!! Hooray!!!
And your Django project is here:
Strangely, the same command doesn‘t work on Windows (with openSSH), it still wants that passphrase, but my correct phrase simply won‘t pass the authentication process. After 3 tries, it rejected me.
[No bother for puTTY which simply uses a differnt format (.ppk) for keys.]
Other notes:
clean the known_hosts
private keys need to be in ~/.ssh folder
puTTY cannot load .pem file, puTTY supports .ppk, use puTTYgen for conversion
How to ssh to your Amazon Elastic Beanstalk instance?
标签:
原文地址:http://www.cnblogs.com/antai/p/4551083.html