I have to connect to a remote sftp server to upload some files using python 2.7. i have been given a username, password and the authentication key file. when i execute this code:
srv= pysftp.Connection(host='54.172.33.121',username='xxx',password='xxx',private_key='c:\SFTPKey\hajjcoreit.ppk')
i get this error:
BadAuthenticationType: ('Bad authentication type', [u'publickey']) (allowed_types=[u'publickey'])
i can access the server through winSCP though.
Edits in your code
You probably have done something wrong with the hostname. As the proper syntax for pysftp is as
import pysftp
sftp = pysftp.Connection('hostname', username='me', password='secret')
#
# ... do sftp operations
#
sftp.close() # close your connection to hostname
so now this is what you do,
srv=pysftp.Connection('sftp.54.172.33.121',username='xxx',password='xxx',private_key='c:\SFTPKey\hajjcoreit.ppk')
so you won't get any error.Also cross check with the filezilla that the link, uid and password are correct.
Related
we try to get the server URL after we enter to the Parse Server packaged by Bitnami we using
cd stack/parse
then
cat config.json
but we get wrong server URL in the terminal we are using mac
"serverURL": "http://127.0.0.1/parse",
that appears in the mongodb
"databaseURI": "mongodb://bn_parse:DqUOZwaxv1aC#127.0.0.1:27017/bitnami_parse"
but the URL server doesn't work
I'm facing Authentication unsuccessful error when I try to send mail from Apache Superset.
I checked the document's SMTP integration chapter:https://apache-superset.readthedocs.io/en/latest/installation.html
I changed SMTP_PASSWORD parameter and I entered password manually in my config.py file like SMTP_PASSWORD = "'xxx!!'" (I added '' because my password includes special character like '!'. Also, I tried SMTP_PASSWORD="xx!!" but also I'm getting error.
smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful')
I can login with my SMTP user via browser (Exchange). Could you please help me to solve this issue?
Apache Superset version: 1.3.2
Python version:3.8
OS version: RHEL 8
Thanks
You might be able to poke at this by checking your SMTP connection from inside your Superset instance.
From where your Superset instance should be sending the emails, start a Python script and try:
import smtplib
server = smtplib.SMTP('smtpservername.yourdomain', yourportnumber)
If that command fails or hangs indefinitely, you know there's a connection problem. You might try connecting to the GMail SMTP server or another known-to-work set of credentials and seeing if that works to narrow it down.
For instance, if running Superset with docker-compose you would enter the worker container with docker exec -it superset_worker /bin/bash, run python, and try this there.
My scheduled reports were failing and doing this helped me isolate a cause: my Superset instance could not connect to the target unauthenticated SMTP server.
I have a problem during adding facebook login button to my website at localhost.
I've already add mysite.com to hosts file and installed django-extensions, werkzeug, pyOpenSSL. By running command python manage.py runserver_plus --cert-file cert.crt my own-made sertificate was created. I imported this certificate to Trusted Chrome sertificates but safe connection doesn't establish. When i pass https://example.com:8000/account/login/ I hit an error NET::ERR_CERT_COMMON_NAME_INVALID,
Failed to confirm that this is the server example.com. Its safety certificate refers to *. The server may be configured incorrectly or someone is trying to intercept your data.
Please help me to solve this.
I am trying to connect to a PostgreSQL Database via ssh tunnel. It is set up to listen on port 3333 and forward to port 5432 on the machine with the database. I am able to connect using the psql command with password authentication via the tunnel, but for some reason when I attempt to connect using psycopg2 via the tunnel, I get the error FATAL: password authentication failed for user database_user. I have tried putting quotes around user names and passwords to no avail.
Successful psql command:
psql -h localhost -p 3333 -U database_name database_user
#This command brings up password prompt
Failed pscyopg2 command:
psycopg2.connect("dbname='database_name' user='database_user' host='localhost' password='database_password' port=3333")
Output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/database_user/.local/share/virtualenvs/project-QNhT-Vzg/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "database_user"
FATAL: password authentication failed for user "database_user"
Here is part of my pg_hba.conf for reference:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
When debugging a connection issue it is always worthy to remember what layers we must go through before reaching the service. When you connect PostgreSQL service there will be at least three layers:
Networking: Firewall, NAT, Port Forwarding
PostgreSQL ACL
PostgreSQL login
It is important to understand what layer cause the issue, the PostgreSQL client (wrapped in psycopg2 in your scenario) error will help you to resolve this by issuing an ad-hoc error message:
Network issue will generally raise a typical: Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?which means you did not succeed to connect the PostgreSQL service at all, problem relies before the service;
ACL issue will generally raise a typical: No pg_hba.conf entry for host <hostname>, user <username>, database <database> which means you did connect the PostgreSQL service but the connection is not referenced as valid in ACL;
Login issue will generally raise the error you have got: password authentication failed for user "<user>" which means you did connect the PostgreSQL service and the connection complies with an ACL entry but the authentication failed.
In the later scenario, it is important to know which entry triggered, because it defines the authentication mode. In your case, it was a md5 entry (because there is no password in peer mode and your SSH tunnel should map the localhost so you are seen as host instead of local for a postgreSQL perspective):
host all all 127.0.0.1/32 md5
Apparently your password is not what you expect it to be. To solve this, ensure:
you have set the password to the postgreSQL user and checked the LOGIN privileges (not the unix/SSH user, there are different concepts);
you use the same password in your psycopg2 connection, then you must be able to connect;
Reading your comment, it seems you may have ' quote in your password as well. So your password in your connection might be:
psycopg2.connect("dbname='database_name' user='database_user' host='localhost' password="'database_password'" port=3333")
Or if the quote are required it may indicate that you use some special characters that need to be escaped. You can also try simpler password to debug and then fallback on a stronger one.
I want to use a batch file to connect to a amazon server by using the ssh private or public key.
I have tried
open sftp://user:password#example.com/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
psftp fred#server.example.com
in the script but I am not able to connect to the server. I am getting this error.
disconnected no supported authentication methods available (server sent publickey)
I am able to connect it from putty. I want a batch file to connect to the server and restart the django project in that.
If I am able to connect then I just need to go the path of my django project and run the command
manage.py runserver
ssh -i PrivateKey.pem username#server.example.com