scp

Check whether a path exists on a remote host using paramiko

一个人想着一个人 提交于 2019-12-21 07:30:20
问题 Paramiko's SFTPClient apparently does not have an exists method. This is my current implementation: def rexists(sftp, path): """os.path.exists for paramiko's SCP object """ try: sftp.stat(path) except IOError, e: if 'No such file' in str(e): return False raise else: return True Is there a better way to do this? Checking for substring in Exception messages is pretty ugly and can be unreliable. 回答1: See the errno module for constants defining all those error codes. Also, it's a bit clearer to

Timeout in paramiko (python)

泪湿孤枕 提交于 2019-12-20 12:21:37
问题 I'm looking for a way to set a timeout for this: transport = paramiko.Transport((host, port)) transport.connect(username = username, password = password) sftp = paramiko.SFTPClient.from_transport(transport) sftp.get(remotepath, localpath) sftp.close() transport.close() 回答1: The connection timeout can be set with the timeout parameter (that indicated the number of seconds for the time out as described here) of the connect function. ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy

Uploading a File via SCP with Maven fails

别等时光非礼了梦想. 提交于 2019-12-20 10:39:53
问题 I try to upload an ear created by maven to an application server using scp. When I tried to run mvn wagon:upload-single But I get the following error: [ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload-single (default-cli) on project de.volkswagen.dps.ear: Unable to create a Wagon instance for null: url can not be null -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3

rsync - create all missing parent directories?

半世苍凉 提交于 2019-12-20 10:17:41
问题 I'm looking for an rsync -like program which will create any missing parent directories on the remote side. For example, if I have /top/a/b/c/d on one server and only /top/a exists on the remote server, I want to copy d to the remote server and have the b and c directories created as well. The command: rsync /top/a/b/c/d remote:/top/a/b/c won't work because /tmp/a/b doesn't exist on the remote server. And if it did exist then the file d would get copied to the path /top/a/b/c . This is

How do I create a directory on remote host if it doesn't exist without ssh-ing in?

久未见 提交于 2019-12-20 09:09:21
问题 I'm not sure if this is possible or not. Basically, I'm writing a script that allows me to scp a file to my hosting. This is it so far. Argument 1 is the file and argument 2 is the folder I want it to be placed in on the remote server: function upload { scp $1 myusername@ssh.myhost.net:$2 } As you may/may not know, if the directory I specify when I call the function doesn't exist, then the transfer fails. Is there a way to check if the directory exists in the function and if it doesn't,

How to resume scp with partially copied files? [closed]

丶灬走出姿态 提交于 2019-12-20 08:06:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 16 days ago . I use scp shell command to copy huge folder of files. But at some point of time I had to kill the running command (by Ctrl+C or kill). To my understanding scp copied files sequentially, so there should be only one partially copied file. How can same scp command be resumed to not overwrite successfully copied

SSH SCP Local file to Remote in Terminal Mac Os X

柔情痞子 提交于 2019-12-20 07:59:02
问题 I am attempting to copy a local file 'magento.tar.gz' from my local machine to a remote server using SSH through a VPN. This is connecting to the Virtual Machine's Internal IP which I've used as xx.x.x.xx here. I have full 'sudo' access on the SSH account so there shouldn't be any problem copying across. I have tried the following: I have tried the following (the magento.tar.gz file is already in the local root dir) sudo scp magento.tar.gz user@xx.x.x.xx/var/www/ This asks me to type in my

How to filter files when using scp to copy dir recursively?

不想你离开。 提交于 2019-12-20 07:58:36
问题 I need to copy all the .class files from server to local with all dir reserved. e.g. server:/usr/some/unknown/number/of/sub/folders/me.class will be /usr/project/backup/some/unknown/number/of/sub/folders/me.class the problem is, there are many other useless files such as .svn-base files that i don't want. how can i filter them so I only scp .class files? 回答1: I'd probably recommend using something like rsync for this due to its include and exclude flags, e.g:- rsync -rav -e ssh --include '*/'

ssh scp等远程登录,拷贝操作

痴心易碎 提交于 2019-12-19 06:04:48
ssh SSH: 远程登录 保证通信的数据安全 需要安装相应的服务端和客户端软件, 安装成功之后就可以使用ssh命令了 软件安装步骤: 假如Ubnutu 作为服务端, 需要安装ssh 服务端软件, 执行命令: sudo apt_get openssh_server macOS 默认安装了ssh客户端软件, 不需要安装,直接可以使用ssh命令 windows 需要安装 OpenSSH for Windows 这个软件 ssh 命令格式为: ssh 用户名@ ip地址 scp scp 是基于ssh进行远程文件拷贝的命令 scp命令格式: 远程拷贝文件 远程拷贝目标 1.scp 本地文件 远程服务器用户名@远程服务器ip地址:指定拷贝到远程服务器的路径 1. scp -r 本地目录 远程服务器用户名@远程服务器ip地址:指定拷贝到远程服务器的路径 2.scp 远程服务器用户名@远程服务器ip地址:远程服务器文件 指定拷贝到本地电脑的路径 2.scp -r 远程服务器用户名@远程服务器ip地址:远程服务器目录 指定拷贝到本地电脑的路径 3.-r 表示递归拷贝整个目录 FileZilla软件 FileZilla 是一个免费开源的FTP软件, 使用可视化方式进行上传和下载文件。以后可以通过 FileZilla 来代替 scp 命令. 小黑板: ssh 命令是远程登录主机电脑,

命令

五迷三道 提交于 2019-12-18 21:49:06
linux virtualenv安装+虚拟环境创建 激活虚拟环境/退出虚拟环境 创建目录/删除目录 scp cuda/cudnn 版本 git 远程仓库(github) 使用 关联本地已有库到远程库 从远程库克隆至本地 分支管理 virtualenv安装+虚拟环境创建 pip3 install virtualenv - - upgrade virtualenv - - system - site - packages ~ / env / tensorflow 激活虚拟环境/退出虚拟环境 source ~ / tensorflow / bin / activate deactive # 19.12.02 update source . / venv / bin / activate deactivate 创建目录/删除目录 mkdir test1 mkdir - p test2 / test22 rm - rf 目录名字 scp scp / opt / soft / nginx - 0.5 .38 . tar . gz root@ 10.10 .10 .10 : / opt / soft / scptest // 从tk传到服务器 scp . / stc / CAFE - MORL - BottomUp - 2metrics / logs / rho_mid / tk@xxx :