elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  conexión ftp con archivo key y chilkat
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: conexión ftp con archivo key y chilkat  (Leído 1,020 veces)
gisierra

Desconectado Desconectado

Mensajes: 1


Ver Perfil
conexión ftp con archivo key y chilkat
« en: 11 Octubre 2023, 20:07 pm »

SOS! actualmente nos conectamos a un servidor mediante  SFTP por chilkat, enviando 4 parámetros que son el dominio, puerto, usuario y clave.
Sucede que ahora que cambiaron el proveedor la clave lo envían con un archivo KEY y no se como leerlo. El software esta en BV6.0

código actual que si funciona:

========================================
Public Function Subre_GUIA(nombreArchivo As String) As Integer
Dim sftp As New ChilkatSFtp
Dim success As Long

success = sftp.UnlockComponent("TALMAS.SS1122018_6FYzL2ydm7mF")

If (success <> 1) Then
    Subre_GUIA = 1
    Exit Function
End If

sftp.ConnectTimeoutMs = 5000
sftp.IdleTimeoutMs = 10000

success = sftp.Connect(gIPFTP_Guia, gPuertoFTP_Guia)
If (success <> 1) Then
    Subre_GUIA = 1
    Exit Function
End If

success = sftp.AuthenticatePw(gUsuarioFTP_Guia, gPasswordFTP_Guia)

If (success <> 1) Then
    Subre_GUIA = 1
    Exit Function
End If

success = sftp.InitializeSftp()
If (success <> 1) Then
    Subre_GUIA = 1
    Exit Function
End If

success = sftp.UploadFileByName("IN/" & nombreArchivo & ".txt", App.Path + "\IN\" & nombreArchivo & ".txt")
If (success <> 1) Then
    Subre_GUIA = 1
    Exit Function
End If

sftp.Disconnect

If (success <> 1) Then
    Subre_GUIA = 1
    Exit Function
End If

Subre_GUIA = 0

End Function
========================
pero no se como setear el password desde el archivo


En línea

TickTack


Desconectado Desconectado

Mensajes: 428


CipherX


Ver Perfil
Re: conexión ftp con archivo key y chilkat
« Respuesta #1 en: 17 Febrero 2024, 16:21 pm »

Quizás ya solucionaste el problema. Pero si no, ya que quiero volver a entrar en el mundo de la programación:

Código:
Public Function Subre_GUIA(nombreArchivo As String) As Integer
    Dim sftp As New ChilkatSFtp
    Dim success As Long
    Dim clave As String
   
    success = sftp.UnlockComponent("TALMAS.SS1122018_6FYzL2ydm7mF")

    If (success <> 1) Then
        Subre_GUIA = 1
        Exit Function
    End If

    sftp.ConnectTimeoutMs = 5000
    sftp.IdleTimeoutMs = 10000

    success = sftp.Connect(gIPFTP_Guia, gPuertoFTP_Guia)
    If (success <> 1) Then
        Subre_GUIA = 1
        Exit Function
    End If

    ' Leer el contenido del archivo KEY y usarlo como clave
    clave = LeerContenidoArchivo("ruta_del_archivo.key")

    success = sftp.AuthenticatePw(gUsuarioFTP_Guia, clave)

    If (success <> 1) Then
        Subre_GUIA = 1
        Exit Function
    End If

    success = sftp.InitializeSftp()
    If (success <> 1) Then
        Subre_GUIA = 1
        Exit Function
    End If

    success = sftp.UploadFileByName("IN/" & nombreArchivo & ".txt", App.Path + "\IN\" & nombreArchivo & ".txt")
    If (success <> 1) Then
        Subre_GUIA = 1
        Exit Function
    End If

    sftp.Disconnect

    If (success <> 1) Then
        Subre_GUIA = 1
        Exit Function
    End If

    Subre_GUIA = 0

End Function

Function LeerContenidoArchivo(rutaArchivo As String) As String
    Dim fso As Object
    Dim archivo As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set archivo = fso.OpenTextFile(rutaArchivo)
    LeerContenidoArchivo = archivo.ReadAll
    archivo.Close
    Set archivo = Nothing
    Set fso = Nothing
End Function

Este código modificado incluye una función adicional llamada LeerContenidoArchivo que se encarga de leer el contenido del archivo KEY. Asegúrate de reemplazar "ruta_del_archivo.key" con la ruta correcta hacia el archivo KEY en tu sistema. Luego, la clave leída se utiliza para autenticarse en el servidor SFTP en lugar de la contraseña directamente.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
sin conexión ?
Wireless en Linux
tipo2 0 1,249 Último mensaje 16 Octubre 2010, 20:00 pm
por tipo2
QTCreatir y librerias chilkat
Programación C/C++
Drakomorh 0 1,938 Último mensaje 17 Diciembre 2011, 23:38 pm
por Drakomorh
Problema de conexión
Programación Visual Basic
werty456 0 1,421 Último mensaje 12 Abril 2012, 00:24 am
por werty456
Mantener conexión abierta en servidor - conexión cliente servidor
Java
cesarobcn 1 2,222 Último mensaje 29 Octubre 2013, 19:13 pm
por egyware
Librería chilkat para C++
Programación C/C++
Kaxperday 1 2,379 Último mensaje 17 Enero 2016, 20:59 pm
por Orubatosu
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines