Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting

Thread Tools Rate Thread Display Modes
Old 03-01-2021, 01:16 PM
FabriceCarboni FabriceCarboni is offline
Registered User
Join Date: Feb 2021
Location: Belgium
Posts: 10
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 ()
Reply With Quote
Old 03-01-2021, 02:35 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,096
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.

Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Old 03-01-2021, 09:34 PM
FabriceCarboni FabriceCarboni is offline
Registered User
Join Date: Feb 2021
Location: Belgium
Posts: 10
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.

Last edited by jdev; 03-02-2021 at 07:34 AM.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 11:22 AM.