Browse Source

write ssh wrapper in shell

pull/126/head
butlerx 7 years ago
parent
commit
2d8f9624c9
No known key found for this signature in database GPG Key ID: B37CA765BAA89170
  1. 10
      Dockerfile
  2. 29
      bin/ssh

10
Dockerfile

@ -1,9 +1,9 @@
FROM node:boron-alpine FROM node:boron-alpine
MAINTAINER butlerx@notthe.cloud
WORKDIR /app WORKDIR /app
RUN adduser -D -h /home/term -s /bin/sh term &&\ RUN adduser -D -h /home/term -s /bin/sh term && \
echo "term:term" | chpasswd echo "term:term" | chpasswd
EXPOSE 3000 EXPOSE 3000
ADD . /app COPY . /app
RUN apk add --update build-base python perl openssh &&\ RUN apk add --update build-base python openssh && yarn
yarn
CMD yarn start CMD yarn start

29
bin/ssh

@ -1,16 +1,15 @@
#!/usr/bin/env perl #!/usr/bin/env sh
my $user_at_address = $ARGV[0]; userAtAddress="$1"
my @u_a = split(/@/, $user_at_address); USER=$(echo "$userAtAddress" | cut -d"@" -f1);
if (defined $u_a[1]) { HOST=$(echo "$userAtAddress" | cut -d"@" -f2);
if ( $^O == 'linux' ) {
exec ("/usr/bin/ssh $u_a[0]\@$u_a[1]"); if [ "$USER" = "$HOST" ]
} then
} else { printf "Enter your username: "
print "Enter your username: "; read -r USER
my $username = <STDIN>; USER=$(echo "${USER}" | tr -d '[:space:]')
chomp ( $username ); ssh "$USER"@"$HOST"
if ( $^O == 'linux' ) { else
exec ("/usr/bin/ssh $username\@$u_a[0]"); ssh "$userAtAddress"
} fi
}

Loading…
Cancel
Save