VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   How to put a file with sftp (

FabriceCarboni 03-01-2021 01:16 PM

How to put a file with sftp

I generated a banner file that I would like to be able to upload on my switch via a sftp connection, I found several solutions like “ paramiko ” or “ pysftp ” but when I try to install or import the modules, it doesn’t work.
Is Someone can help me please, here is my code

def SFTPSession ():
pip install pysftp
import pysftp
import sys

host = str(IPAddr)
password = "Password"
username = "User"
path = './/flash/switch/'
localpath = './Users/fabricecarboni/Downloads/Tftp/'

with pysftp.Connection(host, username=username, password=password, log=./Users/fabricecarboni/Downloads/Tftp/pysftp.log) as sftp:
sftp.put(localpath, path)
SFTPSession ()

jdev 03-01-2021 02:35 PM

Dear FabriceCarboni,

If you're using SecureCRT and you're writing a SecureCRT script then you don't need to employ any non-VanDyke Software products to accomplish SFTP activity.

For example, if you're already able to use SecureCRT to connect with a host using SSH2, then just open an SFTP tab and send the necessary commands to upload the file you desire to that remote host.
Also, please note that your switch must have SFTP server capability to do what you're looking to accomplish.

The text of your example mixes terminology between TFTP and SFTP. If you're trying to automate a transfer via TFTP, then you'll probably still be able to do that since SecureCRT has a built-in TFTP server, but you may need to provide more details about how you would do the TFTP transfer manually from the SecureCRT command line, and then assistance could potentially be provided to help you better understand how you might be able to automate that TFTP transfer.

If you're set on using paramiko or pysftp, you should know that these forums are specific to VanDyke Software products. Assistance with other products like paramiko or pysftp would need to be requested from the vendors/creators of those products.


FabriceCarboni 03-01-2021 09:34 PM

Hello Jdev,

Thanks for your help.
I don't mix technology, the path I'm telling is just a path where files are stored. Your example of code helped me well, now it works fine.

A great thank you for your help.

All times are GMT -6. The time now is 10:13 AM.