Downloading all the files in a directory with cURL

If you’re not bound to curl, you might want to use wget in recursive mode but restricting it to one level of recursion, try the following; wget –no-verbose –no-parent –recursive –level=1 \ –no-directories –user=login –password=pass ftp://ftp.myftpsite.com/ –no-parent : Do not ever ascend to the parent directory when retrieving recursively. –level=depth : Specify recursion maximum depth … Read more

Linux shell to restrict sftp users to their home directories?

OpenSSH≥4.8 supports a ChrootDirectory directive. Add to /etc/sshd_config or /etc/ssh/sshd_config or whatever your setup’s global sshd config file is: Match user ben_files # The following two directives force ben_files to become chrooted # and only have sftp available. No other chroot setup is required. ChrootDirectory /var/www/vhosts/mydomain.example/files ForceCommand internal-sftp # For additional paranoia, disallow all types … Read more

Directory transfers with Paramiko

You can subclass paramiko.SFTPClient and add the following method to it: import paramiko import os class MySFTPClient(paramiko.SFTPClient): def put_dir(self, source, target): ”’ Uploads the contents of the source directory to the target path. The target directory needs to exists. All subdirectories in source are created under target. ”’ for item in os.listdir(source): if os.path.isfile(os.path.join(source, item)): … Read more

“Renci.SshNet.Common.SshException: Invalid private key file” when loading SSH private key from configuration string using SSH.NET

As this is the top answer for that error message, so I think it’s worthwhile expanding on a point in your original question – converting to an OpenSSH format key. Renci.SshNet can’t use PuTTY keys that start with: PuTTY-User-Key-File-2: ssh-rsa You can use puttygen.exe to convert to the OpenSSH format load your key file in … Read more