https://devcenter.heroku.com/articles/python
When i'm trying to deploy my code through $ git push heroku master i get an error:
Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Next, I was able to add the RSA host key for that IP address by $ heroku keys:add but I still get this error:
Found existing public key: /Users/opalkale/.ssh/github_rsa.pub
Uploading SSH public key /Users/opalkale/.ssh/github_rsa.pub... done
(venv)Opal-Kales-MacBook-Pro:helloflask opalkale$ git push heroku master
Permission denied (publickey).
What am I doing wrong...?
Add your id_rsa.pub SSH key to your Heroku account online: https://dashboard.heroku.com/account
And make sure that the corresponding private key has been added to your identity
$ ssh-add ~/.ssh/id_rsa
E.g.
$ ssh-add ~/.ssh/github_rsa
Related
The Problem
I'm getting started with MongoDB on Python, I have a Ubuntu machine in my local network and MongoDB is installed there. When I try to connect with database using Python from Mac it throughs me an error. I searched about it and found out there is a .service called mongod.service that needs to be started along with mongodb.service. But when I try to start the mongod.service the it says the .service doesn't even exist. I tried both with IP and mongodb url, nothing works.
Ubuntu Terminal
$ sudo service mongod start
$ Failed to start mongod.service: Unit mongod.service not found.
$ sudo systemctl start mongod
$ Failed to start mongod.service: Unit mongod.service not found.
DataBase Link (a)
mongodb://user:password#192.168.0.106/database
Python Script (a)
#!/usr/bin/env python3
from pymongo import MongoClient
client = MongoClient('mongodb://user:password#192.168.0.106/database')
db = client['database']
collection = db['collection']
json = dict(message='hello world', token=0)
collection.insert_one(json)
macOS Terminal (a)
pymongo.errors.ServerSelectionTimeoutError: 192.168.0.106:27017: [Errno 61] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 60e140982a43032aef0dd634, topology_type: Single, servers: [<ServerDescription ('192.168.0.106', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('192.168.0.106:27017: [Errno 61] Connection refused')>]>
DataBase Link (b)
mongodb+srv://user:password#cluster0.h9fmz.mongodb.net/database?retryWrites=true&w=majority
Python Script (b)
#!/usr/bin/env python3
from pymongo import MongoClient
client = MongoClient('mongodb+srv://user:password#cluster0.h9fmz.mongodb.net/database?retryWrites=true&w=majority')
db = client['database']
collection = db['collection']
json = dict(message='hello world', token=0)
collection.insert_one(json)
macOS Terminal (b)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/pymongo/pool.py", line 1278, in _get_socket
sock_info = self.sockets.popleft()
IndexError: pop from an empty deque
During handling of the above exception, another exception occurred:
.....
.....
.....
pymongo.errors.OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}
Note That
I'm providing the correct username and password for the database.
I'm using a machine on my local network, which is not a live server.
I've also tried the following commands but they did not solve anything.
Ubuntu Terminal
$ mongod --auth --port 27017
$ mongod --port 27017
$ sudo rm /var/lib/mongodb/mongod.lock
$ sudo mongod --repair
For accessing mongodb from another machine in local network. You will need to check the following:
There is no firewall restriction in the server machine or client machine. In case there is a firewall, you will need to add rule exceptions to allow this port to be accessible. Both incoming and outgoing. (Ubuntu firewall)
You will have to add bindIp config to the mongodb config in server machine. Refer to docs here. You will need to add something like this:
net:
bindIp: 0.0.0.0
port: 27017
Make sure you are able to connect using this ip: 192.168.0.106(server in local network) from the server machine itself. This will make sure the server is listening in this ip.
$ Failed to start mongod.service: Unit mongod.service not found.
The solution for this error could be found here
The mongo atlas error might be due to the following reasons:
You will have to create an database user in order to connect to mongodb.
you can find it under the left panel -> Database access -> Add user
This will be because of a mismatch with username and password. In case you have any special characters in your password you will have to url encode them.
I cloned the application commcare-hq after installing python and django in my cpanel. here's the link: https://github.com/dimagi/commcare-hq but whenever i enter the following command
git submodule update --init --recursive
i get the following error
fatal: clone of 'git://github.com/dimagi/xml2json.git' into submodule path
'/home/hcdcnetl/myProject/commcare-hq/submodules/xml2json' failed
Failed to clone 'submodules/xml2json'. Retry scheduled
Cloning into '/home/hcdcnetl/myProject/commcare-
hq/corehq/apps/hqmedia/static/hqmedia/MediaUploader'...
fatal: unable to connect to github.com:
github.com[0: 192.30.253.113]: errno=Connection refused
github.com[1: 192.30.253.112]: errno=Connection refused
git://github.com is not an SSH URL, it is a Git-protocol URL.
Try
git config --global url."git#github.com/".insteadOf git://github.com/
Any git://github.com/ will be replaced by the SSH URL git#github.com/...
I'm working on win7 and trying to use fabric to push changes to an ubuntu 16.04 VPS. So far I have:
env.roledefs = {
'test': ['localhost'],
'dev': ['user#dev.example.com'],
'production': ['deploy#xxx.xx.xx.xx']
}
#roles('production')
def dir():
env.key_filename = '~/.ssh/id_rsa'
local("pip freeze > requirements.txt")
local("git add . --all && git commit -m 'fab'")
local("git push myproject master")
run('pwd')
...
When I run this the output is:
$ fab dir
[deploy#xx.xx.xx.xx] Executing task 'dir'
[localhost] local: pip freeze > requirements.txt
[localhost] local: git add . --all && git commit -m 'fab'
warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory.
[master warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory.
256de92] 'fab'
warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory.
3 files changed, 10 insertions(+), 9 deletions(-)
[localhost] local: git push example master
debug1: Connecting to 198.91.88.101 [198.91.88.101] port 22.
debug1: connect to address 198.91.88.101 port 22: Connection refused
ssh: connect to host 198.91.88.101 port 22: Bad file number
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Fatal error: local() encountered an error (return code 128) while executing 'git push example master'
So fabric is trying to push to the wrong target ip address (this was an old vps address . I no longer have it.) I got rid of the VPS but saved the public and private key and uploaded the pub key to my new vps at a new ip address
The problem is I'm not sure where the old target address is being set. Is this a git issue. How do I redirect fabric to push to #roles('production')
When I look in my .ssh/known_hosts I see 198.91.88.101. So I'm wondering if that is involved in some way.
It is in the git remote configuration. Verify with git remote --verbose.
So I open the psql terminal (on Windows). I log into it with the server set on localhost,
But when I try to log into it with my production host:
xxxx.compute-1.amazonaws.com
I get the following error:
> psql: FATAL: password authentication failed for user "postgres"
> FATAL: no pg_hba.conf entry for host "128.6.37.14", user "postgres",
> database "campus", SSL off
I tried adding it to the pg_hba.conf, but no luck:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 128.6.37.14/32 trust
Any idea what the issue is? Is the host correct? It's what I got when I ran heroku config
How do I fix this?
I assume you are using Heroku Postgres, the Heroku Database as a Service based on PostgreSQL, right?
If so, you can use the heroku pg:psql CLI command to connect to your Heroku Postgres database from outside of Heroku.
First, issue the following command to get your Heroku Postgres Add-on name:
heroku pg:info
Then you can do:
heroku pg:psql <Add-on>
e.g.
heroku pg:psql postgresql-parallel-XXXXX
I'm working with fabric3 (https://pypi.python.org/pypi/Fabric3) , a python 3 port of fabric.
I have the following function wchich I'm running locally in win7 using git-bash:
#roles('production')
def dir():
env.key_filename = '~/.ssh/deploy'
local("git push mysite master")
run('pwd')
run('ls')
code_dir = '/home/deploy/mysite'
with cd(code_dir):
run('pwd')
run('git reset --hard master')
run('ls -la')
output:
$ fab dir
[deploy#198.x.x.x] Executing task 'dir'
[localhost] local: git push mysite master
deploy#198.x.x.x's password:
When I run the function, I get asked for the password. It seems to be ignoring the key. How can I get the function to use the prescribed key?
I added git as a user to my .ssh/config file and it now appears to work.
Host deploy
HostName 198.x.x.x
User deploy
PreferredAuthentications publickey
IdentityFile ~/.ssh/deploy
IdentitiesOnly yes
Host 198.x.x.x
HostName 198.x.x.x
User git
IdentityFile ~/.ssh/deploy