(17-09-2021, 18:22)Shordi escribió: ssh_config es para la salida de ssh
(17-09-2021, 18:22)Shordi escribió: sshd_config es el puerto para el servidor ssh (la d es de demonio)
(17-09-2021, 17:46)Shordi escribió: -En la station3 no entras como admin. Sino como cada uno de los usuarios y entonces
-creas una clave con:
ssh-genkey
y pulsas enter a todo. Luego:
ssh-copy-id -p <puerto> admin@ipdelservidor
Te pide la clave del admin@ipservidor. Se la pones.
Y ya está. A ese usuario no se le pide más la clave.
(17-09-2021, 21:46)Shordi escribió: Con Sudo su Y luego su usuarioMuy bueno, conocía "su" pero nunca le di importancia.
Siendo root no te pide la clave
' Gambas module file
Public Sub Main()
  Config.Load
  sshfs(["production"])
  Config.Save
  Quit
End
Private Sub sshfs(sGroup As String[])
  Dim sPrivate As String
  Dim sSection As String
  Dim sGlobal As String
  Dim sec As String
  Dim sComm As String
  sPrivate = User.home &/ "server" &/ "private"
  sGlobal = User.home &/ "server" &/ "global"
  '' Private directory
  Shell "mkdir -p " & sPrivate
  sComm = "sshfs -o reconnect -p " & Config.Port & " " & User.Name & "@" & Config.Server & ":" & Config.Dsk &/ User.Name & " " & sPrivate
  Print sComm
  Shell sComm Wait
  '' Global directory
  Shell "mkdir -p " & sGlobal
  sComm = "sshfs -o reconnect -p " & Config.Port & " " & User.Name & "@" & Config.Server & ":" & Config.Glo & " " & sGlobal
  Print sComm
  Shell sComm Wait
  '' Section directory
  For Each sec In sGroup
    If Config.Sections.Exist(sec) Then
      sSection = User.home &/ "server" &/ sec
      Shell "mkdir -p " & sSection
      sComm = "sshfs -o reconnect -p " & Config.Port & " " & User.Name & "@" & Config.Server & ":" & Config.Sec &/ sec & " " & sSection
      Print sComm
      Shell sComm Wait
    Endif
  Next
End
' Gambas class file
Create Static
Export
Private Const ConfigFile As String = ".setup/config.json"
''Configuration variables to be saved, add as needed below
Public Sections As String[] = ["admin", "accounting", "commercial", "marketing", "hr", "managment", "control", "logistic", "purchasing", "production"]
Public Base As String = "server"
Public Server As String = "server"
Public Port As String = "22" '' The server port default is 22 but, for increase the safety, is recomended to change to other.
Public Group As String = "workgroup" '' Is the name of the team is the root name where will be mounted all the shared directories.
Public Dsk As String = "/var/desktops"
Public Sec As String = "/var/sections"
Public Glo As String = "/var/global"
Public Admin As String = "superuser"
'' Here you have to pass all the global variables that are scattered in other classes or modules.
Public Sub Load(Optional sFile As String)
  Dim jConfig As Collection
  Dim sSymbol As String
  Dim obj As Object = Me
  Dim MyClass As Class = Object.Class(obj)
  If sFile = "" Then
    sFile = User.Home &/ ConfigFile
  Endif
  If Exist(sFile) Then
    jConfig = JSON.FromString(File.Load(sFile))
    For Each sSymbol In myClass.Symbols
      If jConfig.Exist(sSymbol) Then
        Object.SetProperty(obj, sSymbol, jConfig[sSymbol])
      Endif
    Next
  Endif
End
Static Public Sub Save(Optional sFile As String)
  Dim jConfig As New JSONCollection
  Dim obj As Object = Me
  Dim MyClass As Class = Object.Class(obj)
  Dim Var As String
  Dim Valor As Variant
  If sFile = "" Then
    sFile = User.Home &/ ConfigFile
  Endif
  For Each Var In myClass.Symbols
    '' Verifying that it is a property or a variable.
    If (MyClass[var].kind = Class.Variable) Or (MyClass[var].kind = Class.Property) Then
      valor = Object.GetProperty(obj, var)
      jConfig.Add(Valor, var)
    End If
  Next
  If Not Exist(File.Dir(sFile)) Then
    Shell "mkdir -p " & File.Dir(sFile) Wait
  Endif
  File.Save(sFile, JSON.Encode2(jConfig))
EndCREATE TABLE `unidades` (
 `rowid` int NOT NULL AUTO_INCREMENT,
 `permiso` varchar(10) COLLATE utf8_spanish_ci NOT NULL,
 `pathservidor` varchar(1024) COLLATE utf8_spanish_ci NOT NULL,
 `pathlocal` varchar(1024) COLLATE utf8_spanish_ci NOT NULL,
 `comentarios` text COLLATE utf8_spanish_ci NOT NULL,
 `usr` varchar(50) CHARACTER SET utf8 COLLATE utf8_spanish_ci NOT NULL,
 `fmod` datetime NOT NULL,
 PRIMARY KEY (`rowid`),
 UNIQUE KEY `permiso` (`permiso`)
)Public Sub unidades()
    
    Dim r As Result
    Dim aperm As String[]
    Dim sLocal, sremoto, scomando As String
    Dim npuerto As String
    
    npuerto = 55555 'número establecido estándar de la aplicación
    aperm = Split(m.entorno["permisos"], "|")
    r = m.hcon.Exec("select * from ad_unidades where substr(`codigo`,2)='UD' order by `codigo` DESC") 'se ordena inverso para que los _RO se evalúen primero
    scomando = "sshfs -o reconnect -p " & nPuerto & " administrador@10.8.0.1:" & sremoto & " " & sLocal Wait
    While r.Available
        If aperm.Exist(r!codigo) Then
            sLocal = normaliza(r!pathLocal)
            sremoto = normaliza(r!pathservidor)
            If Not Exist(sLocal) Then
                 Mkdir slocal
            Endif
            Shell scomando Wait
        Endif
    Wend
    
End
Private Sub normaliza(cpath As String) As String
    
    cpath = Subst(cpath, "<nick>", m.entorno["nick"])
    cpath = Subst(cpath, "<sede>", m.entorno["sede"])
    cpath = Subst(cpath, "<sector>", m.entorno["sector"])
    Return cpath
    
End