Heroku deployment of Django app unsuccessful - python

I am trying to deploy a Django app to Heroku but I get this strange error when i run the following command.
Any idea why this happens? I've googled it but I found nothing that would help.
root#ubuntu:~/Desktop/djangos/jobs# git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.154' to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Thanks in advance for any hints/help!

I had same problem , Add your ssh key to heroku by $ heroku keys:add .
check out my blogpost http://www.codesucksmybrain.blogspot.com/2012/04/deploy-django-app-on-heroku-platform.html

Firstly,you should login.
$ heroku login
Enter your Heroku credentials.
Email: adam#example.com
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
Also, if you login, you should try "git pull heroku master" then try to "git push heroku master".
Getting Started

verify that the name of the SSH-KEY is "id_rsa" and that the secret key is the one you believe in this file, if it is safe to re-create the key and leave it with that name "id_rsa"

Related

Heroku login issue ENOENT [duplicate]

After a fresh install of Heroku on Windows 7, I can't seem to authenticate from the command-line.
Running the command: heroku login prompts me to enter my credentials. After doing so, I received an error:
heroku: Enter your login credentials
Email: my_email
Password: ************
Error: ENOENT: no such file or directory, open 'z:/_netrc'
I am using PowerShell, and when I run the command cat z:/_netrc, I get this error:
cat : Cannot find drive. A drive with the name 'z' does not exist.
Z: is a network drive, and it is accessible from the file explorer.
I already have a .netrc file in my %HOME% path, but it does not contain the heroku login credentials.
Looking at the official documentation and CLI help, I couldn't find anything useful to fix this. How can I login to my heroku account?
> heroku version
heroku/7.16.6 win32-x64 node-v10.11.0
So, the issue is arising from not finding _netrc file on your local computer that is required to complete login with Heroku. I have decided to create the file into following location of my windows 10 computer:
cmd>set HomeDrive=C:/Users/your Windows username/AppData/Local/heroku
In my case,
cmd>set HomeDrive=C:/Users/CrazyMoby/AppData/Local/heroku
Finally I ran heroku login
The above step resolved heroku login issue in my case.
Use setx HOME <netrc_default_location>
where <netrc_default_location> can be:
<%NETRC%>\_netrc
<%HOME%>\_netrc
<%HOMEDRIVE%%HOMEPATH%>\_netrc
<%USERPROFILE%>\_netrc
Some clarification can be found here and here.
Probably it's your user <%USERPROFILE%>.
But if you don't need it, just remove _netrc file, reboot and log in again.
Run the following command in powershell and the problem should be solved.
$Env:HOMEDRIVE = "C:"
If you need more information, check out the docs on windows environment variables.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7
This way work for me. Write in PowerShell next code , where "paulob" need change to your user, because folser "_netrc" exist in:
$Env:HOMEDRIVE = "C:\Users\paulob\"
Try running it from GIT BASH cmd instead of PowerShell if you can, I had the same problem and it worked in my case.

Set credentials to pull from local git repository with PythonGit

I have a git repository on an internal server and now want to have a scheduled task that automatically pulls changes to my local version. Found the GitPython package, which seems to be exactly what I need, but can't get it to work due to the password protection of the repo.
I have already cloned the repo to my local path (git clone git#LOCAL_IP:/repo/MY_GIT.git .) and will get prompted for the password every time I execute git pull from the command line (fair enough). According to How can I call 'git pull' from within Python?, I then tried exactly this
import git
g = git.cmd.Git(MY_LOCAL_PATH)
g.pull()
and (of course) get an error:
...
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git pull
stderr: 'Permission denied, please try again.
Permission denied, please try again.
...
Unfortunately, from the many answers around the web dealing with PythoGit, I found none that tells me how I can set the password (I know that you should never ever hardcode passwords, but still...).
You can save credentials within git so that every git client can access them and won't ask the user. See How can I save username and password in Git? for details on how to do that.

Can't connect to PyMongo DB on Kubernetes

Everything worked fine when I ran it on Docker, but after I migrated it to Kubernetes it stopped connecting to the DB. It says:
pymongo.errors.ServerSelectionTimeoutError
pymongo.errors.ServerSelectionTimeoutError: connection closed
whenever I try to access a page that uses the DB.
I connect like this:
app.config['MONGO_DBNAME'] = 'pymongo_db'
app.config['MONGO_URI'] = 'mongodb://fakeuser:FakePassword#ds1336984.mlab.com:63984/pymongo_db'
Any way to get it to connect?
Edit:
I think it has more so to do with the Istio sidecars as when deployed on Kubernetes minus Istio, it runs normally. The issue only appears when running Istio.
Most likely Istio (the Envoy sidecar) is controlling egress traffic. You can check if you have any ServiceEntry and VirtuaService in your cluster for your specific application:
$ kubectl -n <your-namespace> get serviceentry
$ kubectl -n <your-namespace> get virtualservice
If they exist, check if they are allowing traffic to ds1336984.mlab.com. If they don't exist you will have to create them.

I got an error while using "git push heroku master" command

When I'm trying to push python project on heroku using git push heroku master
command I got an error like this.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How can I solve this error?
You have to add your ssh keys to heroku by running heroku keys:add. Heroku can then verify you and allow access to your repository on heroku. More on this here: https://devcenter.heroku.com/articles/keys

Provide a password for the "git push" command in GitPython

In Python, using GitPython, I need to git push to a HTTPS remote repository on BitBucket.
After running the repo.git.push() command, it will return -as expected-:
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Password for 'https://username#bitbucket.org': Invalid argument'
But Python will give me no change to enter the password like in the console.
How can I "attach" the password to the git push command or how can simulate a console password entry in Python?
It is important to note that unfortunately using SSH is not an alternative (the script should not requiere any further action to user that receives it and that wants to git push). I'm looking to "attach" the password into the command or to "simulate" a text entry on it.
What you are attempting to is skirt past security.
You need to create a pair of ssh keys.
Then, log-on to your bitbucket account's website and upload your public key.
Store your keys in your ~/.ssh directory.
When you have your keys setup you will not be prompted for a password anymore.
Here is more information about working with SSH keys: https://help.github.com/articles/generating-an-ssh-key/

Categories

Resources