Browse Source

write ssh wrapper in shell

pull/123/head
butlerx 7 years ago
committed by cbutler
parent
commit
a9a1aa1690
No known key found for this signature in database GPG Key ID: 9EB3D625BD14DDEC
  1. 6
      Dockerfile
  2. 29
      bin/ssh

6
Dockerfile

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

29
bin/ssh

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

Loading…
Cancel
Save