LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
379 stars 108 forks source link

No such file or directory: /dev/ttyUSB0 #80

Closed jl2035 closed 4 years ago

jl2035 commented 4 years ago

Ubuntu 18.04.2 LTS.

I'm not sure if this is the right repo to open this issue, but I've got nowhere else to go as I've googled a lot and I'm dealing with this for weeks already.

I can't get "Gemalto USB Shell Token V2" smart card to work in Linux. I would like to use it for SSH connection to a remote server. First obvious thing to try was this command, that I found all over the internet:

ssh -I /usr/lib/x86_64-linux-gnu/p11-kit-proxy.so  user@remote-host

But this just asks me for password, so it doesn't detect the card: debug1: pkcs11_add_provider: provider /usr/lib/x86_64-linux-gnu/p11-kit-proxy.so returned no keys

I've tried many things and my latest desperate attempt was to follow this guide:

https://sourceforge.net/p/openlte/wiki/Programming%20you%20own%20USIM%20card/

When I run "sudo pcsc_scan" and plug in the USB, it gets detected:

Mon Aug  5 08:56:46 2019
 Reader 0: Gemalto USB Shell Token V2 00 00
  Card state: Card inserted,
...

But then when I run "./pySim-read.py" I get some exception:

Using serial reader (port=/dev/ttyUSB0, baudrate=9600) interface
Traceback (most recent call last):
  File "./pySim-read.py", line 92, in <module>
    sl = SerialSimLink(device=opts.device, baudrate=opts.baudrate)
  File "/home/user/Prog/Pyscard/pysim/pySim/transport/serial.py", line 45, in __init__
    baudrate = baudrate,
  File "/home/user/Prog/Pyscard/venv/local/lib/python2.7/site-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/home/user/Prog/Pyscard/venv/local/lib/python2.7/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'
Exception AttributeError: "'SerialSimLink' object has no attribute '_sl'" in <bound method SerialSimLink.__del__ of <pySim.transport.serial.SerialSimLink object at 0x7fe0bdf6c490>> ignored

I suspect that the problem is that device does not get bound to /dev/ttyUSB0 and then everything fails. This is what happens in syslog when I plug in the device:

Aug  5 08:56:46 JLR kernel: [1028292.668329] usb 1-1.1: new full-speed USB device number 11 using ehci-pci
Aug  5 08:56:46 JLR kernel: [1028292.786813] usb 1-1.1: New USB device found, idVendor=08e6, idProduct=3438, bcdDevice= 1.00
Aug  5 08:56:46 JLR kernel: [1028292.786818] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Aug  5 08:56:46 JLR kernel: [1028292.786820] usb 1-1.1: Product: USB SmartCard Reader
Aug  5 08:56:46 JLR kernel: [1028292.786822] usb 1-1.1: Manufacturer: Gemplus
Aug  5 08:56:46 JLR mtp-probe: checking bus 1, device 11: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1"
Aug  5 08:56:46 JLR mtp-probe: bus: 1, device: 11 was not an MTP device
Aug  5 08:56:46 JLR upowerd[1857]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1
Aug  5 08:56:46 JLR upowerd[1857]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0

Is there a way to fix this, or is it simply impossible to use Gemalto smart cards on Linux.

On Windoz I could just use Putty CAC and this same device to connect to a SSH remote host. Painless. It's sad that we have to go trough such trouble on the other side :(

LudovicRousseau commented 4 years ago

Your issue has nothing to do with pyscard.

You can try to ask for help on the MUSCLE mailing list https://lists.infradead.org/mailman/listinfo/pcsclite-muscle or the OpenSC mailing list https://github.com/OpenSC/OpenSC/wiki/Mailing-lists

A good starting point can be the FAQ https://github.com/OpenSC/OpenSC/wiki/Frequently-Asked-Questions

jl2035 commented 4 years ago

Hi, thanks for your reply.

I've read trough FAQ and I found out that you can verify if the card is supported using:

opensc-tool --name

And I get this output:

Using reader with a card: Gemalto USB Shell Token V2 00 00
Failed to connect to card: Internal error

Does that mean that I'm just wasting time?

If not, I should give mailing lists a try, although I've never used that before.