相关疑难解决方法(0)

使用Paramiko SSH设置virtualenv

我在Windows中使用Python和Django的经验有限,现在我想了解如何将代码部署到Ubuntu 16.04 LTS VPS。阅读了关于SE的各种教程和很多答案之后,我设法进行了很长时间(对我而言),但是现在我陷入了困境。

手动(通过腻子)我可以执行以下操作:

# check that Python 3.5 is installed
python3 --version  
# install pip
sudo -kS apt-get -y install python3-pip  
# upgrade pip to newest version
pip3 install --upgrade pip
# check result
pip3 --version  
# install venv
sudo -kS pip3 install virtualenv virtualenvwrapper 
# create venv
virtualenv ~/Env/firstsite  
# make sure venv is created 
ls -l ~/Env/firstsite/bin/python  # /home/droplet/Env/firstsite/bin/python3.5 -> python3
# switch on venv
source ~/Env/firstsite/bin/activate  # (firstsite) droplet@hostname:~$
# check that python3 is taken …
Run Code Online (Sandbox Code Playgroud)

python ssh ubuntu virtualenv paramiko

5
推荐指数
1
解决办法
1165
查看次数

使用 paramiko 的无密码 SSH

问题:我是 Paramiko 的菜鸟,试图从远程服务器上的 python 脚本(在个人机器上)运行一些命令。远程服务器不需要密码即可连接。

例如,如果我root@[IPaddress]在 Mac 上执行此操作,则 可以通过 MacbookPro 终端成功连接到远程服务器。

但是,我正在尝试使用 Paramiko 在 Python 脚本中执行此操作,无论我做什么,都会收到身份验证错误或无可用身份验证方法。

我经历了Paramiko AuthenticationException 问题,但在没有大量 Paramiko 经验的情况下,我的答案含糊不清。帮助?

这是我的代码:

import paramiko
import os
from paramiko import SSHClient

#Borrowed from the linked post 
class SSHClient_noauth(SSHClient):
    def _auth(self, username, *args):
        self._transport.auth_none(username)
        return

#How do I implement? 
ssh =  SSHClient()
sshc = SSHClient_noauth()._auth(username="root") #Where's the ssh obj passed?
sshc.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sshc.connect("10.xxx.xxx.xxx") 
Run Code Online (Sandbox Code Playgroud)

python ssh paramiko

5
推荐指数
1
解决办法
4761
查看次数

使用身份的 Fabrics 2.x ssh 连接无法工作

尝试使用 Fabrics 2 和身份文件连接到 ssh 配置中描述的主机。

con = Connection('my_host')
@task
def tt(c):
    con.run('uname -a')
Run Code Online (Sandbox Code Playgroud)

〜/ .ssh /配置:

Host my_host
    HostName 123.144.76.84
    User ubuntu
    IdentityFile ~/.keys/somekey
Run Code Online (Sandbox Code Playgroud)

它失败了

paramiko.ssh_exception.AuthenticationException:身份验证失败。

$ ssh my_host从终端工作。

我尝试过得到fab -i ~/.keys/somekey tt相同的结果。

python ssh fabric python-fabric-2

5
推荐指数
1
解决办法
2028
查看次数

Paramiko 协议错误:预期数据包 SSH_MSG_USERAUTH_REQUEST,得到 SSH_MSG_SERVICE_REQUEST

当我使用 ssh 命令手动连接到主机时,一切正常:

$ ssh -v admin@mycli.abc.com -p 10000
OpenSSH_6.1p1, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /home/todd/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to mycli.abc.com [mycli.abc.com] port 10000.
debug1: Connection established.
debug1: identity file /home/todd/.ssh/id_rsa type 1
debug1: identity file /home/todd/.ssh/id_rsa-cert type -1
debug1: identity file /home/todd/.ssh/id_dsa type -1
debug1: identity file /home/todd/.ssh/id_dsa-cert type -1
debug1: identity file /home/todd/.ssh/id_ecdsa type -1
debug1: identity file /home/todd/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version SSHD-CORE-0.6.0 …
Run Code Online (Sandbox Code Playgroud)

python ssh paramiko

3
推荐指数
1
解决办法
5745
查看次数

标签 统计

python ×4

ssh ×4

paramiko ×3

fabric ×1

python-fabric-2 ×1

ubuntu ×1

virtualenv ×1