Upload files using SFTP in Python, but create directories if path doesn’t exist

SFTP supports the usual FTP commands (chdir, mkdir, etc…), so use those: sftp = paramiko.SFTPClient.from_transport(transport) try: sftp.chdir(remote_path) # Test if remote_path exists except IOError: sftp.mkdir(remote_path) # Create remote_path sftp.chdir(remote_path) sftp.put(local_path, ‘.’) # At this point, you are in remote_path in either case sftp.close() To fully emulate mkdir -p, you can work through remote_path recursively: import … Read more

Java SFTP server library? [closed]

How to setup an SFTP server using Apache Mina SSHD: public void setupSftpServer(){ SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(22); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(“hostkey.ser”)); List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthNone.Factory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setCommandFactory(new ScpCommandFactory()); List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>(); namedFactoryList.add(new SftpSubsystem.Factory()); sshd.setSubsystemFactories(namedFactoryList); try { sshd.start(); } catch (Exception e) { e.printStackTrace(); } } And that’s all.

Keep Remote Directory Up-to-date

lsyncd seems to be the perfect solution. it combines inotify (kernel builtin function which watches for file changes in a directory trees) and rsync (cross platform file-syncing-tool). lsyncd -rsyncssh /home remotehost.org backup-home/ Quote from github: Lsyncd watches a local directory trees event monitor interface (inotify or fsevents). It aggregates and combines events for a few … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)