diff --git a/Dockerfile b/Dockerfile index d188ee0..d3b6e1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,13 @@ -FROM alpine:3.6 +FROM alpine:3.7 LABEL maintainer="Amir Mofasser (@amimof)" COPY sshd_config /etc/ssh/sshd_config COPY server / -RUN apk add --no-cache --update openssh bash \ +RUN set -x \ +&& apk add --no-cache --update openssh bash \ && mkdir -p /var/run/sshd \ && chmod +x /server -EXPOSE 22 - CMD ["/server"] diff --git a/kubeconfig.yaml b/kubeconfig.yaml deleted file mode 100644 index 9942c32..0000000 --- a/kubeconfig.yaml +++ /dev/null @@ -1,77 +0,0 @@ -apiVersion: v1 -kind: List -items: - - apiVersion: v1 - kind: ServiceAccount - metadata: - name: sftp - - apiVersion: v1 - kind: Service - metadata: - labels: - app: sftp - name: sftp - spec: - ports: - - name: ssh - port: 2222 - protocol: TCP - targetPort: ssh - selector: - deploymentConfig: sftp - sessionAffinity: None - type: NodePort - - apiVersion: v1 - kind: DeploymentConfig - metadata: - name: sftp - spec: - replicas: 1 - selector: - deployment-config.name: sftp - strategy: - activeDeadlineSeconds: 21600 - resources: {} - rollingParams: - intervalSeconds: 1 - maxSurge: 25% - maxUnavailable: 25% - timeoutSeconds: 600 - updatePeriodSeconds: 1 - type: Rolling - template: - metadata: - creationTimestamp: null - labels: - deployment-config.name: sftp - deploymentConfig: sftp - spec: - containers: - - env: - - name: SSH_GENERATE_HOSTKEYS - value: "false" - - name: SSH_USERNAME - value: sftpuser - image: amimof/sftp - imagePullPolicy: Always - name: sftp - ports: - - containerPort: 22 - name: ssh - protocol: TCP - readinessProbe: - tcpSocket: - port: 22 - initialDelaySeconds: 5 - resources: {} - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - dnsPolicy: ClusterFirst - restartPolicy: Always - schedulerName: default-scheduler - securityContext: {} - serviceAccount: sftp - serviceAccountName: sftp - terminationGracePeriodSeconds: 30 - test: false - triggers: [] \ No newline at end of file diff --git a/pod.yaml b/pod.yaml new file mode 100644 index 0000000..73c7779 --- /dev/null +++ b/pod.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + name: sftp +spec: + containers: + - name: sftp + image: amimof/sftp + env: + - name: SSH_USERNAME + value: "beyonce" + - name: SSH_PASSWORD + value: "knowles" + ports: + - containerPort: 22 \ No newline at end of file diff --git a/server b/server index 90fae49..6983bb2 100644 --- a/server +++ b/server @@ -42,6 +42,12 @@ else sed -i "s/PasswordAuthentication\s[^ ]*/PasswordAuthentication yes/g" /etc/ssh/sshd_config fi +# Set Port to listen on +if [ ! -z "$SSH_PORT" ]; then + echo "INFO: Setting Port to ${SSH_PORT}" + sed -i "s/Port\s[^ ]*/Port ${SSH_PORT}/g" /etc/ssh/sshd_config +fi + # Change ownership and permissions of users home root dir echo "INFO: Change ownership and permissions of home directory" chown root:root /home/$SSH_USERNAME diff --git a/sshd_config b/sshd_config index 41719f2..0863531 100644 --- a/sshd_config +++ b/sshd_config @@ -1,4 +1,5 @@ Protocol 2 +Port 22 UseDNS no PermitRootLogin no X11Forwarding no