ssh

SQLAlchemy through Paramiko SSH

一世执手 提交于 2021-02-06 09:06:52
问题 I have a database on a server which I need to access through SSH. Right now I deal with the DB by using the command line to get the data. import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname='XX.XX.XX', username='user', password='pass', port = YYY) query = "mysql -u " + username_sql + " -p" + password_sql +" dbb -e \"" + sql_query + "\"" ssh.exec_command(query.decode('string_escape')) ssh.close() Is there a way to do this

Ansible provisioning ERROR! Using a SSH password instead of a key is not possible

醉酒当歌 提交于 2021-02-05 21:35:25
问题 I would like to provision with my three nodes from the last one by using Ansible. My host machine is Windows 10. My Vagrantfile looks like: Vagrant.configure("2") do |config| (1..3).each do |index| config.vm.define "node#{index}" do |node| node.vm.box = "ubuntu" node.vm.box = "../boxes/ubuntu_base.box" node.vm.network :private_network, ip: "192.168.10.#{10 + index}" if index == 3 node.vm.provision :setup, type: :ansible_local do |ansible| ansible.playbook = "playbook.yml" ansible.provisioning

Ansible provisioning ERROR! Using a SSH password instead of a key is not possible

天涯浪子 提交于 2021-02-05 21:35:09
问题 I would like to provision with my three nodes from the last one by using Ansible. My host machine is Windows 10. My Vagrantfile looks like: Vagrant.configure("2") do |config| (1..3).each do |index| config.vm.define "node#{index}" do |node| node.vm.box = "ubuntu" node.vm.box = "../boxes/ubuntu_base.box" node.vm.network :private_network, ip: "192.168.10.#{10 + index}" if index == 3 node.vm.provision :setup, type: :ansible_local do |ansible| ansible.playbook = "playbook.yml" ansible.provisioning

deploy with capistrano using a pem file

爱⌒轻易说出口 提交于 2021-02-05 13:44:44
问题 We have a EC2 instance, and our capistrano setup requires ssh. To connect through ssh normally, I use a .pem file for connecting to the server. how do I utilize this .pem file when using capistrano to deploy? 回答1: In deploy.rb set these configuration values: default_run_options[:pty] = true ssh_options[:forward_agent] = true ssh_options[:auth_methods] = ["publickey"] ssh_options[:keys] = ["/path/to/key.pem"] For Capistrano 3 use: set :pty, true set :ssh_options, { forward_agent: true, auth

deploy with capistrano using a pem file

五迷三道 提交于 2021-02-05 13:43:41
问题 We have a EC2 instance, and our capistrano setup requires ssh. To connect through ssh normally, I use a .pem file for connecting to the server. how do I utilize this .pem file when using capistrano to deploy? 回答1: In deploy.rb set these configuration values: default_run_options[:pty] = true ssh_options[:forward_agent] = true ssh_options[:auth_methods] = ["publickey"] ssh_options[:keys] = ["/path/to/key.pem"] For Capistrano 3 use: set :pty, true set :ssh_options, { forward_agent: true, auth

deploy with capistrano using a pem file

家住魔仙堡 提交于 2021-02-05 13:43:00
问题 We have a EC2 instance, and our capistrano setup requires ssh. To connect through ssh normally, I use a .pem file for connecting to the server. how do I utilize this .pem file when using capistrano to deploy? 回答1: In deploy.rb set these configuration values: default_run_options[:pty] = true ssh_options[:forward_agent] = true ssh_options[:auth_methods] = ["publickey"] ssh_options[:keys] = ["/path/to/key.pem"] For Capistrano 3 use: set :pty, true set :ssh_options, { forward_agent: true, auth

Run awk comand on a remote server through ssh

血红的双手。 提交于 2021-02-05 11:46:45
问题 I'm trying to get a specific set of values from a file on a remote server. The command works fine when executing that through terminal. First ssh Command sshpass -p password ssh -T user@ip Second Awk Command find /opt/Info_Source/*daily* -type f -mtime -1 -exec zcat {} \; 2>/dev/null | awk -F, -v OFS=',' '$5 ~ /Valid/ && length($2) {print $2}' but if I combine both of them in a script #!/bin/ksh emp_id=`sshpass -p password ssh -T user@ip -q << EOF find /opt/Info_Source/*daily* -type f -mtime

Paramiko module not found

时光总嘲笑我的痴心妄想 提交于 2021-02-05 11:27:07
问题 When I try to import paramiko , when I try to run rforward.py from the paramiko demo files, it shows error : ./rforward.py Traceback (most recent call last): File "./rforward.py", line 36, in <module> import paramiko ImportError: No module named paramiko And when I try to install paramiko via pip, pip install paramiko It shows : Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (2.6.0) My python version is 2.7.18 . I had installed paramiko for a different python3

setting a local bash variable from an ssh command

社会主义新天地 提交于 2021-02-05 09:46:54
问题 I am running a chain of sshpass > ssh > commands, I would like to store the exit code of one of those commands ran in the remote server in a variable so I can access it back in the local after ssh is done. What I have done so far does not seem to store anything. Help please! My Code: sshpass -p password ssh user@ip "echo \"first command\" ; su -lc \"./root_script.sh\" ; set MYVAR = $? ; rm root_script.sh \" if (( $MYVAR != 0 )) ; then echo "Cannot continue program without root password" exit

Bash assign output to variable inside here document

我与影子孤独终老i 提交于 2021-02-05 09:46:06
问题 In a bash script, what I need is to ssh to a server and do some commands, what I got so far is like this: outPut="ss" ssh user@$serverAddress << EOF cd /opt/logs outPut="$(ls -l)" echo 'output is ' $outPut EOF echo "${outPut}" But the output from terminal is: output is ss ss The output was assigned to the output from command ls -l , but what it showed is still the original value, which is ss . What's wrong here? 回答1: There are actually two different problems here. First, inside a here