https://raw.githubusercontent.com/paramiko/paramiko/master/demos/demo_server.py
I see the above demo_server of paramiko. But I don't see the instructions on how to run it. I run the following ./demo_server.py command. But once I run ssh robey#127.0.0.1 -p 2200, the server fails. Could anybody let me know the complete steps on how to run this example? Thanks.
$ python3 ./demo_server.py
Read key: 60733844cb5186657fdedaa22b5a57d5
Listening for connection ...
Got a connection!
*** Caught exception: <class 'ImportError'>: Unable to import a GSS-API / SSPI module!
Traceback (most recent call last):
File "./demo_server.py", line 140, in <module>
t = paramiko.Transport(client, gss_kex=DoGSSAPIKeyExchange)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/transport.py", line 445, in __init__
self.kexgss_ctxt = GSSAuth("gssapi-keyex", gss_deleg_creds)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/ssh_gss.py", line 107, in GSSAuth
raise ImportError("Unable to import a GSS-API / SSPI module!")
ImportError: Unable to import a GSS-API / SSPI module!
$ ssh robey#127.0.0.1 -p 2200
kex_exchange_identification: read: Connection reset by peer
I managed to get it to work, make sure to go through these steps (Thank you Sandeep for the pip insight), chances are you may be missing the Kerberos dependencies:
You may need to perform pip install gssapi in the CLI if that has not already been done (I'm using the Windows Command Prompt, Linux/WSL might need pip3 instead depending on your version of python)
From there you will need to import the gssapi library into the code at the top with the other imported libraries, so just call
import gssapi in demo_server.py
After running demo_server.py again, the CLI should eventually say something like it is missing files located in Program Files\ MIT\ Kerberos\ bin, as Kerberos is a dependency for gssapi, you can install it from here:
https://web.mit.edu/KERBEROS/dist/
Make sure you do custom install if you're not sure where it will be downloaded, so that you can set up the file location where the CLI says is missing in step 3 (Should automatically say Program Files\ MIT). I unchecked the boxes for auto-start and tickets, but not sure as to what your preferences may be. After all that, a computer restart is required.
Related
I tried to make a function that checks if my Ubuntu Server has a specific package installed via apt list, when the condition isn't met it, in theory, the program should install any necessary dependencies for the other piece of software to work. Here's a function I wrote:
# Docker Configuration Tool
def DCT():
cache = apt.Cache()
if cache['docker-ce'].is_installed:
print("Docker and Docker-compose are installed on this system...")
print("If you don't have MySQL Server installed on your system use Docker to prepare and configure your Server")
__run_file = [ BASH COMMANDS ]
OS_MCE(__run_file)
else:
print("Docker and Docker-compose are not installed on this system!")
print("Preparing Environment for the Installation...\n")
__install_docker = [ BASH COMMANDS ]
OS_MCE(__install_docker)
An error when trying to run this function:
Traceback (most recent call last):
File "MIM.py", line 304, in <module>
NSWIT(True)
File "MIM.py", line 297, in NSWIT
Menu()
File "MIM.py", line 257, in Menu
DCT()
File "MIM.py", line 117, in DCT
if cache['docker-ce'].is_installed:
File "/usr/lib/python3/dist-packages/apt/cache.py", line 305, in __getitem__
raise KeyError('The cache has no package named %r' % key)
KeyError: "The cache has no package named 'docker-ce'"
Try changing your if expression to check that the docker-ce key is in the cache map before trying to access it. If there isn't a key with that name, it makes sense to assume that the package isn't installed. So like this:
# Docker Configuration Tool
def DCT():
cache = apt.Cache()
if 'docker-ce' in cache and cache['docker-ce'].is_installed:
print("Docker and Docker-compose are installed on this system...")
print("If you don't have MySQL Server installed on your system use Docker to prepare and configure your Server")
__run_file = [ BASH COMMANDS ]
OS_MCE(__run_file)
else:
print("Docker and Docker-compose are not installed on this system!")
print("Preparing Environment for the Installation...\n")
__install_docker = [ BASH COMMANDS ]
OS_MCE(__install_docker)
Error messages are your friend. Read them carefully. In this case, the error was telling you precisely what was wrong, and with that, it is obvious how to fix it once you've been doing this for a while.
This is a good opportunity to learn about and understand short-circuited evaluation of logical expressions. The first clause of your conditional expression insures that the second clause isn't evaluated if it will throw the error you were seeing (well, Duh!, right?)...but if you don't fully understand why that is, it's a good thing to clearly understand. Maybe see: https://pythoninformer.com/python-language/intermediate-python/short-circuit-evaluation/
I am using Python 3 on Raspberry PI and after a proper shutdown and power on of the system again I noticed that Python is no longer working. Note that it took several attempts to properly boot Raspberry PI (power on/off) due to a reason I am not sure of yet. After the boot I tried launching a custom program and the Python interpreter itself. In both cases I got ValueError: bad marshal data (unknown type code) I referred to the steps provided here to fix that problem: How to fix Python ValueError:bad marshal data?
What I did is as follows:
sudo find /usr -name '*.pyc' -delete without sudo I cannot delete
sudo update && sudo upgrade
pi#raspberrypi:~ $ python3 Fatal Python error: initsite: Failed to
import the site module Traceback (most recent call last): File
"/usr/lib/python3.7/site.py", line 79, in
import os File "/usr/lib/python3.7/os.py", line 191
def makedirs(name, mode=0o777, exist_ok=False):
"""makedirs(name [, mode=0o777][, exist_ok=False])
^ SyntaxError: invalid syntax
I am not able to resolve this issue. Do you have any suggestions? Can it be related with a symbolic link pointing the wrong direction or a file corruption?
I am getting following error even after having following packages installed. Recently os has been upgraded and python has been updated from 2.5 to 2.7 and before that application was using 2.7.11 which is installed on local folder.
After up gradation I am unable to run my scirpts and getting following ssl error.
File "/itStorage/tools/swutils/pylibs/shu/common.py", line 5, in <module>
import ssl
File "/itStorage/tools/swutils/deps/python_2.7.11/lib/python2.7/ssl.py", line 97, in
import _ssl # if we can't import it, let the error propagate
ImportError: libssl.so.6: cannot open shared object file: No such file or directory
After searching google it may be due to openssl packages or libssl path. we have every thing in place even after that we having issue.
[aafedc#afeae ~]$ sudo rpm -qa *openssl*
openssl-1.0.2k-8.el7.x86_64
openssl-devel-1.0.2k-8.el7.x86_64
openssl-libs-1.0.2k-8.el7.i686
openssl-libs-1.0.2k-8.el7.x86_64
openssl098e-0.9.8e-29.el7_2.3.i686
[abcd#abcd ~]$ sudo ls -l /usr/lib/libssl.so.6*
lrwxrwxrwx. 1 root root 16 May 25 03:34 /usr/lib/libssl.so.6 -> libssl.so.0.9.8e
any help is greatly appropriated!!..
Thanks in advance.
You could try to run the script using strace, then you should see what fails.. I'm not sure but I think it could be a missing dependency of libssl as well or permissions problem.
OS: Fedora 21
Python: 2.7.6
I run a python script as root or using sudo it runs fine. If I run it as just the user I get the following:
Traceback (most recent call last):
File "/home/user/dev_ad_list.py", line 12, in
import ldap
ImportError: No module named ldap
selinux=disabled -- What other security is preventing a user from running a python script that imports ldap
If it works fine under sudo, it simply sounds like a file access issue.
A quick fix for this would be to run something along the lines of:
sudo chmod -R a+rX /usr/lib/python2.7
But you may wish to be more specific with the directory (or even file) that you actually apply this to.
Path to python was different than other user. User was pointing to canopy.
Good day,
I'm a student and I would just like to ask for a minute of your time.
I'm working on a barcode reader connected via USB port to a board name Arduino Yun. This board runs a version of embedded linux derived from OpenWrt using a microprocessor named Atheros AR9331
I would like to ask you, what's necessary to make the Python Evdev binding (python-evdev.readthedocs.org/en/latest/), to be able to run in this type of MIPS microarchitecture? At the momento, it's only for Ubuntu and ArchLinux.
I'm kind of guessing that cross compilation would be needed, or the indication of the usage of a specific C compiler inside this linux.
The current python version supported for OpenWrt is 2.7.3
I already know , if you compile C code in your PC, the resulting executable will only run in this type of architecture. If you use that compiled program inside the microprocessor, it wont work.
I've used this binding without trouble within ubuntu in my PC. I followed the instructions, python setup.py install, with a previous installation of setuptools, and it worked just fine.
But regarding OpenWrt, this was not the case.
The python script I'm using requires this library within the first line of code in order to reach the data from the device (it works like a keyboard /dev/input/event0):
#!/usr/bin/env python
from evdev import InputDevice, ecodes, list_devices
from select import select
I've seen suggestions of copying the entire library inside the arduino, and run the script inside the same folder. But it doesn't work, since the evdev module has files created with the architecture of the PC and not the MIPS.
So, what are the messages displayed for the error?
If you run python setup.py install in Openwrt to try to install the evdev binding, this appears on screen:
File "setup.py", line 10, in <module>
from setuptools.command.develop import develop
ImportError: No module named setuptools.command.develop
It's obvious from here that you need the module aforementioned. So, I tried to install it with this script (pypi.python.org/pypi/setuptools):
python ez_setup.py
And the output shows this:
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip
Traceback (most recent call last):
File "ez_setup.py", line 332, in <module>
sys.exit(main())
File "ez_setup.py", line 327, in main
downloader_factory=options.downloader_factory,
File "ez_setup.py", line 287, in download_setuptools
downloader(url, saveto)
File "ez_setup.py", line 209, in download_file_curl
_clean_check(cmd, target)
File "ez_setup.py", line 169, in _clean_check
subprocess.check_call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 511, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['curl','https://pypi.python.org/packages/source/s/setuptools/setuptools-11.3.1.zip', '--silent', '--output', '/mnt/sda1/evdev-0.4.6/setuptools-11.3.1.zip']' returned non-zero exit status 60
I pressume this output is due to the fact that pypi doesn't exist for the python 2.7.3 in OpenWrt , only for newer versions and other architectures. Evedv binding is requiring the setuptools module in order to make things easier and standard, but if the binding is not supported for the target architecture, what's needed to be able to use it anyways?
Thanks for your time,
Good day everyone,
The solution was provided by Georgi Valkov. He is the creator of the python-evdev binding. I contacted him directly, and he was so kind that he cross compiled a version for the OpenWrt / Yun .
You can install the package using the openwrt package manager - opkg. The installation process is along the lines of:
$ opkg update
$ opkg install /path/to/python-evdev_0.4.7-1_ar71xx.ipk
To verify that the install was successful:
$ opkg files python-evdev
/usr/lib/python2.7/site-packages/evdev-0.4.7-py2.7.egg-info
/usr/lib/python2.7/site-packages/evdev/genecodes.py
/usr/lib/python2.7/site-packages/evdev/ff.py
/usr/lib/python2.7/site-packages/evdev/_input.so
/usr/lib/python2.7/site-packages/evdev/device.py
/usr/lib/python2.7/site-packages/evdev/events.py
/usr/lib/python2.7/site-packages/evdev/__init__.py
/usr/lib/python2.7/site-packages/evdev/ecodes.py
/usr/lib/python2.7/site-packages/evdev/_ecodes.so
/usr/lib/python2.7/site-packages/evdev/util.py
/usr/lib/python2.7/site-packages/evdev/uinput.py
/usr/lib/python2.7/site-packages/evdev/_uinput.so
This works just fine. Thanks.
PS. If someone needs the file, please contact me. Georgi sent me this address, but I didn't download the file from there because he sent it to me over email.
https://github.com/gvalkov/openwrt-packages-yun/blob/master/lang/python-evdev/Makefile
In the output, you can see that curl returned the status code 60. According to man curl
60 Peer certificate cannot be authenticated with known CA certifiā
cates.
According to the setuptools page, you can instead use python ez_setup.py --insecure but obviously do that at your own risk. Alternatively you could do what the advanced instructions say and manually download the setuptools tarball, verify its md5 hash yourself, and install it using its setup.py .