sftp

SFTP: return number of files in remote directory?

末鹿安然 提交于 2019-12-30 10:43:58
问题 I sent a batch of files to a remote server via SFTP. If it were a local directory I could do something like this ls -l | wc -l to get the total number of files. However, with SFTP, I get an error Can't ls: "/|" not found . 回答1: echo ls -l | sftp server | grep -v '^sftp' | wc -l If you want to count the files in a directory the directory path should be put after the ls -l command like echo ls -l /my/directory/ | sftp server | grep -v '^sftp' | wc -l 回答2: Use a batch file to run commands

How To Handle Incoming Files In Apache Mina SSHD SFTP Server in Java

喜你入骨 提交于 2019-12-30 10:03:06
问题 Currently i am working on a SFTP protocol.I have created SFTP client Using Jsch Library and SFTP Server using Apache Mina Sshd library.I have made connection between them and can successfully send files to SFTP server.Now i am working on creating a SFTP server side file handler that handles the incoming files.As a example let say SFTP server can receive files from SFTP client but currently in my implementation there is no way to notify when file is arrived into server.I just go server root

How To Handle Incoming Files In Apache Mina SSHD SFTP Server in Java

故事扮演 提交于 2019-12-30 10:02:25
问题 Currently i am working on a SFTP protocol.I have created SFTP client Using Jsch Library and SFTP Server using Apache Mina Sshd library.I have made connection between them and can successfully send files to SFTP server.Now i am working on creating a SFTP server side file handler that handles the incoming files.As a example let say SFTP server can receive files from SFTP client but currently in my implementation there is no way to notify when file is arrived into server.I just go server root

LEMP + wordpress file permissions to be able to edit, upgrade and use sftp client

女生的网名这么多〃 提交于 2019-12-30 05:25:46
问题 I am trying to manage file permissions on a debian webserver that runs nginx, so that wordpress can edit, upload and upgrade without having to use ftp. I also want to be able to login using sftp with my user account. I am aware of the fact that this question has been asked before, see here or here, but following the steps in those answers hasn't been satisfying. The setup currently looks as follows: The wordpress folder is in /var/www/html/ I made a new user ("user") and group ("group"). The

Using Apache Mina as a Mock/In Memory SFTP Server for Unit Testing

风格不统一 提交于 2019-12-30 04:00:06
问题 I am having a bit of trouble working out how to use Apache Mina. Their documentation is a bit scant for my talentless brain to work out. I have seen the helpful starting code at Java SFTP server library? What I can't figure out is how to use it. I want to setup a unit test that checks my sftp code, using Mina as a kind of mock server, i.e., be able to write a unit test like: @Before public void beforeTestSetup() { sshd = SshServer.setUpDefaultServer(); sshd.setPort(22); sshd

paramiko模块

强颜欢笑 提交于 2019-12-28 17:25:53
SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接: import paramiko # 创建SSH对象 ssh = paramiko.SSHClient() # 允许连接不在know_hosts文件中的主机 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # 连接服务器 ssh.connect(hostname='c1.salt.com', port=22, username='wupeiqi', password='123') # 执行命令 stdin, stdout, stderr = ssh.exec_command('df') # 获取命令结果 result = stdout.read() # 关闭连接 ssh.close() SSHClient 封装 Transport import paramiko transport = paramiko.Transport(('hostname', 22)) transport.connect(username='wupeiqi', password='123') ssh = paramiko.SSHClient() ssh._transport = transport stdin, stdout, stderr = ssh.exec

paramiko 模块 ---- python2.7

会有一股神秘感。 提交于 2019-12-28 17:24:24
模拟远程执行命令: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import paramiko #设置日志记录 paramiko.util.log_to_file( '/tmp/test' ) #建立连接 ssh = paramiko.SSHClient() #缺失host_knows时的处理方法 ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #连接远程客户机器 ssh.connect( '10.1.6.190' ,port = 22 ,username = 'root' ,password = 'password' ,compress = True ) #获取远程命令执行结果 stdin, stdout, stderr = ssh.exec_command( 'hostname;uptime' ) print stdout.read()# 其中其他各类的提示在stderr, stdin中(如错误提示) #输出执行结果 ssh.close() 模拟远程文件传输: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import paramiko

Python:paramiko模块

穿精又带淫゛_ 提交于 2019-12-28 17:23:17
1.安装paramiko pip install paramiko 2.paramiko ssh使用 (1)用密码ssh host = '192.168.101.130' user = 'root' password = '123456' cmd = sys.argv[1] s = paramiko.SSHClient()  #绑定实例 s.load_system_host_keys()  #加载本机HOST主机文件 s.set_missing_host_key_policy(paramiko.AutoAddPolicy())  #目的是接受不在本地Known_host文件下的主机。取消第一次ssh时的交互 s.connect(host,22,user,password,timeout=5)  #远程连接 sdtin,stdout,sdterr = s.exec_command(cmd)  #执行命令并绑定实例,sdtin输入sdtout输出sdterr错误 results = sdtout.read(),sdterr.read() for i in results:  #遍历输出   print i (2)使用key登陆 pkey_file = '/home/zhangshun/.ssh/id_rsa' key = paramiko.RSAKey.from_private_key

python之旅:并发编程

元气小坏坏 提交于 2019-12-26 12:05:01
一 背景知识 顾名思义,进程即正在执行的一个过程。进程是对正在运行程序的一个抽象。 进程的概念起源于操作系统,是操作系统最核心的概念,也是操作系统提供的最古老也是最重要的抽象概念之一。操作系统的其他所有内容都是围绕进程的概念展开的。 所以想要真正了解进程,必须事先了解操作系统, 点击进入 PS:即使可以利用的cpu只有一个(早期的计算机确实如此),也能保证支持(伪)并发的能力。将一个单独的cpu变成多个虚拟的cpu(多道技术:时间多路复用和空间多路复用+硬件上支持隔离),没有进程的抽象,现代计算机将不复存在。 必备的理论基础: #一 操作系统的作用: 1:隐藏丑陋复杂的硬件接口,提供良好的抽象接口 2:管理、调度进程,并且将多个进程对硬件的竞争变得有序 #二 多道技术: 1.产生背景:针对单核,实现并发 ps: 现在的主机一般是多核,那么每个核都会利用多道技术 有4个cpu,运行于cpu1的某个程序遇到io阻塞,会等到io结束再重新调度,会被调度到4个 cpu中的任意一个,具体由操作系统调度算法决定。 2.空间上的复用:如内存中同时有多道程序 3.时间上的复用:复用一个cpu的时间片 强调:遇到io切,占用cpu时间过长也切,核心在于切之前将进程的状态保存下来,这样 才能保证下次切换回来时,能基于上次切走的位置继续运行 本文将将着重介绍进程以及它的亲戚->线程 二

FTP vs SFTP vs HDFS vs NTFS vs EXT2, EXT3 [closed]

走远了吗. 提交于 2019-12-25 18:39:11
问题 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 5 years ago . I just want to know how these protocols and file systems are related with each other, where each one is used. FTP vs SFTP vs HDFS vs NTFS vs EXT2, EXT3 any help would be appreciated. Thanks. 回答1: FTP is an old File Transfer Protocol, similar to HTTP but specialized for moving large files. sftp is a totally