[問題] 請問paramiko如何切換使用者
小弟是使用python3
目前有兩個環境 一個是用root登入,另外是只能用一般使用者登入
如何用root登入後切換一般使用者
或是一般使用者登入切換成root?
感謝
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=ip,port=22,username='root',password=pw,timeout=5)
stdin, stdout, stderr = ssh.exec_command('su - james')
stdin, stdout, stderr = ssh.exec_command('whoami')
print(stdout.readlines())
ssh.close()
目前這樣寫會卡死無回應
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.75.55.2
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1533281921.A.46E.html
※ 編輯: phoenixcx (203.75.55.2), 08/03/2018 15:39:05
推
08/03 19:34,
7年前
, 1F
08/03 19:34, 1F
→
08/03 19:35,
7年前
, 2F
08/03 19:35, 2F
→
08/03 19:35,
7年前
, 3F
08/03 19:35, 3F
→
08/03 19:42,
7年前
, 4F
08/03 19:42, 4F
→
08/03 19:42,
7年前
, 5F
08/03 19:42, 5F
→
08/03 19:43,
7年前
, 6F
08/03 19:43, 6F
→
08/03 19:44,
7年前
, 7F
08/03 19:44, 7F
→
08/03 19:45,
7年前
, 8F
08/03 19:45, 8F
→
08/03 19:47,
7年前
, 9F
08/03 19:47, 9F
→
08/03 19:48,
7年前
, 10F
08/03 19:48, 10F
→
08/03 21:22,
7年前
, 11F
08/03 21:22, 11F
→
08/03 21:22,
7年前
, 12F
08/03 21:22, 12F
→
08/03 21:22,
7年前
, 13F
08/03 21:22, 13F
→
08/03 21:24,
7年前
, 14F
08/03 21:24, 14F
→
08/03 21:24,
7年前
, 15F
08/03 21:24, 15F
→
08/03 21:26,
7年前
, 16F
08/03 21:26, 16F
→
08/04 22:16,
7年前
, 17F
08/04 22:16, 17F
Python 近期熱門文章
PTT數位生活區 即時熱門文章