반응형

출처 : https://stackoverflow.com/questions/43267157/python-attributeerror-module-object-has-no-attribute-ssl-st-init

파이썬 AttributeError: 'module' 객체는 'SSL_ST_INIT' 속성이 없습니다

저의 파이썬 스크립트는 다음 오류가 발생했습니다.

Traceback (most recent call last):
  File "./inspect_sheet.py", line 21, in <module>
    main()
  File "./inspect_sheet.py", line 12, in main
    workbook_name=workbook_name,
  File "./google_sheets.py", line 56, in __init__
    self.login()
  File "./google_sheets.py", line 46, in login
    self.client = gspread.authorize(credentials)
  File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 335, in authorize
    client.login()
  File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 98, in login
    self.auth.refresh(http)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 598, in refresh
    self._refresh(http.request)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 769, in _refresh
    self._do_refresh_request(http_request)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 795, in _do_refresh_request
    body = self._generate_refresh_request_body()
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1425, in _generate_refresh_request_body
    assertion = self._generate_assertion()
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1554, in _generate_assertion
    private_key, self.private_key_password), payload)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/crypt.py", line 162, in from_string
    from OpenSSL import crypto
  File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

20개의 답변 중 1개의 답변만 추려냄

저는 pip로 pyopenssl 업그레이드 하는 것이 pip와 관련된 명령어 중에서는 작동하는 것이 없었습니다. easy_installpyopenssl을 업그레이드 함으로써, 위의 문제는 해결될 수 있습니다.

sudo python -m easy_install --upgrade pyOpenSSL

credit @delimiter (Answer)

반응형
반응형
출처 

http://www.linuxproblem.org/art_9.html

비밀번호 없이 SSH 로그인

목표

당신이 리눅스를 사용하고 당신의 작업을 자동화하기 위해 OpenSSH를 사용하기 원합니다. 그래서 당신은 host A / 사용자 a에서 호스트 B / 사용자 b로 자동 로그인이 필요합니다. 당신은 쉘 스크립트(shell script)로 ssh를 호출하고 싶기 때문에 비밀번호를 입력하길 원하지 않을것입니다.

방법

우선 호스트 A에서 a 사용자로 로그인하여 인증 키 쌍을 생성합니다. passphrase는 입력하지 않습니다.

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A


이제 호스트 B에서 b 사용자로 ssh 프로그램을 사용하여 ~/.ssh 디렉터리를 만듭니다. (디렉터리가 이미 있을지 모르지만 괜찮습니다.)

a@A:~> ssh b@B mkdir -p .ssh
b@B's password:


마지막으로 a 사용자의 새로운 공개키를 b@B:.ssh/authorized_keys에 추가하고 마지막으로 b 사용자의 비밀번호를 입력합니다.

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:


이제부터 비밀번호 없이 호스트 B의 b 사용자로 로그인 할 수 있습니다.

a@A:~> ssh b@B


독자중 한명으로부터 당신의 SSH 버젼에 따라 당신은 다음 작업을 해야할 수 있습니다. 

  • .ssh/authorized_keys2에 public key를 넣습니다.
  • .ssh 디렉터리 권한을 700으로 변경(chmod)합니다.
  • .ssh/authorized_keys2의 권한을 640으로 변경합니다.

다음 출처 : https://opentutorials.org/module/432/3742

역자 추가내용 : 호스트 B의 b 사용자는 .ssh 디렉터리에 다음 권한처럼 설정이 필요합니다.

1
2
3
4
5
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub 
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts


반응형

+ Recent posts