[英]How to send HTTP GET request from remote host using SSH connection in Python?
[英]How to send GET request from remote host using SSH connection in Python?
如何從連接的遠程主機發送 GET 請求。 我通過CMD試過了。首先我登錄到ssh root,然后發送這個請求:
curl -X GET "https://bsms.its.com.pk/otpsms.php?key=xxxxx&receiver=xxx&sender=xxxx¶m1=uxxser&otpcode=1234"
有用。 我正在嘗試在我的 python flask 中做同樣的事情,但它不起作用。
username = 'root'
hostname = '175.111.0.26'
port = 22
password='passowrd'
def do_it():
s = paramiko.SSHClient()
s.load_system_host_keys()
s.connect(hostname, port, username, password)
command = "https://bsms.its.com.pk/otpsms.php?key=xxx&receiver=number&sender=xxxx¶m1=xxx&otpcode=1234"
command.request("GET", '/')
s.exec_command(command)
print(command)
s.close()
那這個呢?
# Connect to the remote host client = paramiko.SSHClient() client.load_system_host_keys() client.connect(hostname, username=username, password=password) # Send the GET request using the `curl` command stdin, stdout, stderr = client.exec_command('curl ' + url) # Print the response print(stdout.read()) # Close the connection client.close()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.