atmoz / sftp

Securely share your files
https://hub.docker.com/r/atmoz/sftp/
MIT License
1.57k stars 813 forks source link

SFTP- server Image is not running in kubernetes #365

Open ankitdahiya07 opened 1 year ago

ankitdahiya07 commented 1 year ago

Sftp-server image is not running on Kubernetes. I followed this doc- https://gist.github.com/jujhars13/1e99cf110e5df39d4ae3c7fef81589f8

Below is my deployment file-

kind: Deployment
apiVersion: apps/v1
metadata:
  name: sftp-atmoz
  namespace: dtac-dev-dev-apps
  labels:
    app: sftp-atmoz
spec:
  # how many pods and indicate which strategy we want for rolling update
  replicas: 1
  selector:
    matchLabels:
      app: sftp-atmoz
  template:
    metadata:
      labels:
        app: sftp-atmoz

    spec:
      #secrets and config
      volumes:
      - name: sftp-public-keys
        configMap:
          name: sftp-public-keys

      containers:
        #the sftp server itself
        - name: sftp-atmoz
          image: tabxcnoper01.snlhrprshared1.gbucdsint02lhr.oraclevcn.com/patchset5/atmoz-sftp:latest
          imagePullPolicy: Always
       #   env:
#      #      - name: PASSWORD
#      #          valueFrom:
#      #            secretKeyRef:
#      #              name: sftp-server-sec
#      #              key: password
          args: ["testuser::1001:100:incoming,outgoing"] #create users and dirs
          ports:
            - containerPort: 22
          volumeMounts:
            - mountPath: /home/testuser/.ssh/keys
              name: sftp-public-keys
              readOnly: true
      imagePullSecrets:
      - name: brmregsecret
---
kind: Service
apiVersion: v1
metadata:
  name: sftp-atmoz
  namespace: dtac-dev-dev-apps
  labels:
    app: sftp-atmoz
spec:
  type: NodePort
  externalIPs:
  - 100.76.208.220
  ports:
  - name: ssh
    port: 22
    targetPort: 22
    nodePort: 31117
  selector:
    app: sftp-atmoz

Configmap-

apiVersion: v1
data:
  id_rsa.pub: |
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC8v2iMS0uL5LlsKepUwudzCos6yt5qsOq3rM0QySmn1+/691IlFg3g/T7xccSeqm/FBv3a5WymB+YY2qHS4Wl6l0CvhG1mZ0DQ3dWj7b6KQOVx3xMVfgVPkXUnV1f4nGzNIBe1X5EsZXvBePLii+Mf5P2STm7mWP2zGpLz71QZpZOJ0SdxeuXtoAgVD/9jcYC2TRCtNPdIK+5xgE9gTJWoMBeRDO8JfpNaezo7eMu8zyP2R0ErI3MNS+yibYwXaxyynlW+lbkOldsn+aCOIEp8FVosuM3r4uFYeAU5Kte3tIowOwjfdoV/pEa9uzjDGXQwHnSOdbdjocENHsRSMntKA9GyCCOqgHW/bTpLGywzZR56S+9zxvoahEpk5DIoNkkzREMX0daOsI0MUYnTyr7+Feips0kQP0MydWKCOM6yh4h6F1XmSjE3BfjxYIMl0hFirIwhLSoo1lMhgZE9jaaJloFqmEVgP9+6iuMyBAL60/vCNUUPPR7TmIEAwtjVxPuFxFlgZbFHYjQdUo3BL6h0JwIYJk1I2X7qvmL+HFUKQJX/10mJlumUNL/NSInZRpMwdjSKVXiKlE4sKotoblnYBeTwWCPOOupZTl97qG2eLJM1sAoOXV+RxOdgTyixTnVCErZuJo5vVJM9L3Pny86l5Y7DksRJBWdD8SBmxr5l5w== dtacdevops@lhr-190
kind: ConfigMap
metadata:
  managedFields:
  - apiVersion: v1
  name: sftp-public-keys
  namespace: dtac-dev-dev-apps

====================================================================================== Facing issue when trying ssh or sftp from inside the pod-

root@sftp-atmoz-7c75d585cc-9qvkd:/# ssh -v localhost OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for debug1: Connecting to localhost [::1] port 22. debug1: Connection established. debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa_sk type -1 debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: identity file /root/.ssh/id_ed25519_sk type -1 debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /root/.ssh/id_xmss type -1 debug1: identity file /root/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.4p1 Debian-5+deb11u1 debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5+deb11u1 debug1: match: OpenSSH_8.4p1 Debian-5+deb11u1 pat OpenSSH* compat 0x04000000 debug1: Authenticating to localhost:22 as 'root' debug1: SSH2_MSG_KEXINIT sent Connection reset by ::1 port 22

SFTP error- root@sftp-atmoz-7c75d585cc-9qvkd:/home/testuser/.ssh/keys# sftp -v localhost OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for debug1: Connecting to localhost [::1] port 22. debug1: Connection established. debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa_sk type -1 debug1: identity file /root/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: identity file /root/.ssh/id_ed25519_sk type -1 debug1: identity file /root/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /root/.ssh/id_xmss type -1 debug1: identity file /root/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.4p1 Debian-5+deb11u1 debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5+deb11u1 debug1: match: OpenSSH_8.4p1 Debian-5+deb11u1 pat OpenSSH* compat 0x04000000 debug1: Authenticating to localhost:22 as 'root' debug1: SSH2_MSG_KEXINIT sent Connection reset by ::1 port 22 Connection closed

9techijcore commented 7 months ago

Hello, Did you fixed ?

ankitdahiya07 commented 6 months ago

Hello, Did you fixed?

Yes, It was resolved by adding a line "privileged: true" in yaml file.