ssh

Pass dict as an argument over SSH to Python script

大兔子大兔子 提交于 2020-12-25 18:58:52
问题 I am trying to pass dict arguments using the ssh command via the os module: os.system(f'ssh remote_host python -u - {dict1} {dict2} < local_script.py') I am getting an error: sh:line:0 syntax error near unexpected token (' What is the right syntax to pass dict as an argument? If I pass string instead of dict, it works fine. Any suggestions? 回答1: Use json and urlencode. import urllib.parse import json dict1_j = urllib.parse.quote(json.dumps(dict1)) dict2_j = urllib.parse.quote(json.dumps(dict2

Azure Post Deployment Script Commands

空扰寡人 提交于 2020-12-15 06:06:43
问题 I have a Django web app on Azure. I'm using Azure's built in continuous deployment, so I don't have any .deployment files within my repo. However, in order for my application to work correctly, I have to manually install a couple packages after that aren't available via pip. So after every deployment, I have to SSH into the deployment and execute the following 2 commands: source home/site/wwwroot/pythonenv3.6/bin/activate sudo apt-get install XXX XXX XXX I believe I can simply execute this

Azure Post Deployment Script Commands

瘦欲@ 提交于 2020-12-15 06:03:58
问题 I have a Django web app on Azure. I'm using Azure's built in continuous deployment, so I don't have any .deployment files within my repo. However, in order for my application to work correctly, I have to manually install a couple packages after that aren't available via pip. So after every deployment, I have to SSH into the deployment and execute the following 2 commands: source home/site/wwwroot/pythonenv3.6/bin/activate sudo apt-get install XXX XXX XXX I believe I can simply execute this

SSH auth fails with “Host key verification failed” despite providing valid keys

时光怂恿深爱的人放手 提交于 2020-12-15 04:54:27
问题 In Azure DevOps Pipelines I want to SSH to a private repo with dependencies. I am getting following error: Host key verification failed. fatal: Could not read from remote repository. Despite uploading private key to secure files and public key is set in project variables. see below steps: - task: InstallSSHKey@0 inputs: hostName: $(hostname) sshPublicKey: $(testkey.pub) sshPassphrase: $(passphrase) sshKeySecureFile: testkey - script: | git clone git@github.xxxxxx.com:xxxx/xxxxx.git

How to split an SSH address + path?

核能气质少年 提交于 2020-12-12 05:22:56
问题 A Python 3 function receives an SSH address like user@132.243.32.14:/random/file/path . I want to access this file with the paramiko lib, which needs the username, IP address, and file path separately. How can I split this address into these 3 parts, knowing that the input will sometimes omit the username ? 回答1: str.partition and rpartition will do what you want: def ssh_splitter(ssh_connect_string): user_host, _, path = ssh_connect_string.partition(':') user, _, host = user_host.rpartition('

Github multiple accounts - Permission to personalUserName/repoName.git denied to globalUserName

余生长醉 提交于 2020-12-11 12:42:09
问题 Update 5/14/2018 I updated my OS and had to reboot my machine, so this apparently messed up my fix to this issue, which seems to have been temporary. To temporarily fix this again, I had to do the following: ran eval "$(ssh-agent -s)" ssh-add ~/.ssh/your-ssh-key enter you ssh key passsphrase run any git command you want I need to look into making this permanent. It is definitely related to me commenting out the Host * section from my .ssh/config file, so I need to figure out how to use

Python unit tests run function after all test

让人想犯罪 __ 提交于 2020-12-08 05:54:11
问题 I need to test smth on python via ssh. I don't want to make ssh connection for every test, because it is to long, I have written this: class TestCase(unittest.TestCase): client = None def setUp(self): if not hasattr(self.__class__, 'client') or self.__class__.client is None: self.__class__.client = paramiko.SSHClient() self.__class__.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.__class__.client.connect(hostname=consts.get_host(), port=consts.get_port(), username=consts

Python unit tests run function after all test

怎甘沉沦 提交于 2020-12-08 05:52:24
问题 I need to test smth on python via ssh. I don't want to make ssh connection for every test, because it is to long, I have written this: class TestCase(unittest.TestCase): client = None def setUp(self): if not hasattr(self.__class__, 'client') or self.__class__.client is None: self.__class__.client = paramiko.SSHClient() self.__class__.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.__class__.client.connect(hostname=consts.get_host(), port=consts.get_port(), username=consts

Python unit tests run function after all test

[亡魂溺海] 提交于 2020-12-08 05:52:10
问题 I need to test smth on python via ssh. I don't want to make ssh connection for every test, because it is to long, I have written this: class TestCase(unittest.TestCase): client = None def setUp(self): if not hasattr(self.__class__, 'client') or self.__class__.client is None: self.__class__.client = paramiko.SSHClient() self.__class__.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.__class__.client.connect(hostname=consts.get_host(), port=consts.get_port(), username=consts

Nested SSH with Paramiko and RSA key file

坚强是说给别人听的谎言 提交于 2020-12-08 04:53:29
问题 I am trying to nested SSH using Paramiko where I will connect to Server X from my local machine and from there I will connect to Server Y. Here to connect to Server X I am using username, password authentication and to connect to Server Y using username and RSA key. The thing is that the RSA key is hosted in System X which is used to connect Server Y. I was able to run the script successfully if I hosted the keyfile in my local PC and gave the local pc directory path to Paramiko SSH client.