butlerx
					
					5 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: B37CA765BAA89170
						
					
				
			
		
		
		
	
		
			
				 4 changed files with 
21 additions and 
11 deletions
			 
			
		 
		
			
				- 
					
					
					 
					Dockerfile
				
 
			
				- 
					
					
					 
					docker-compose.yml
				
 
			
				- 
					
					
					 
					package.json
				
 
			
				- 
					
					
					 
					src/server/command/ssh.ts
				
 
			
		
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					@ -1,4 +1,4 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					FROM node:carbon-alpine as builder | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					FROM node:dubnium-alpine as builder | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					RUN apk add -U build-base python | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					WORKDIR /usr/src/app | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					COPY . /usr/src/app | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -6,7 +6,7 @@ RUN yarn && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    yarn build && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    yarn install --production --ignore-scripts --prefer-offline | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					FROM node:carbon-alpine | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					FROM node:dubnium-alpine | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					LABEL maintainer="butlerx@notthe.cloud" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					WORKDIR /usr/src/app | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					ENV NODE_ENV=production | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -17,6 +17,9 @@ COPY package.json /usr/src/app | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					COPY index.js /usr/src/app | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					RUN apk add -U openssh-client sshpass && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mkdir ~/.ssh && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ssh-keyscan -H wetty-ssh >> ~/.ssh/known_hosts | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    echo '#!/usr/bin/env sh' >> /entrypoint.sh && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    echo 'ssh-keyscan -H wetty-ssh >> ~/.ssh/known_hosts' >> /entrypoint.sh && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    echo 'node .' >> /entrypoint.sh && \ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    chmod +x /entrypoint.sh | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					ENTRYPOINT [ "node", "." ] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					ENTRYPOINT [ "/entrypoint.sh" ] | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -3,7 +3,7 @@ version: '3.5' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					services: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  wetty: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    build: . | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    image: butlerx/wetty | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    image: wettyoss/wetty | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    container_name: wetty | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    tty: true | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    working_dir: /usr/src/app | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -13,7 +13,6 @@ services: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      SSHHOST: 'wetty-ssh' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      SSHPORT: 22 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      NODE_ENV: 'development' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    command: yarn start --sshhost redbrick.dcu.ie | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  web: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    image: nginx | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -37,7 +36,7 @@ services: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    build: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      context: . | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      dockerfile: ssh.Dockerfile | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    image: butlerx/wetty:ssh | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    image: wettyoss/wetty:ssh | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    container_name: 'wetty-ssh' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					networks: | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -45,7 +45,7 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    "wetty": "./index.js" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  "engines": { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    "node": ">=6.9" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    "node": ">=10.22" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  "nodemonConfig": { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    "ignore": [ | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -3,11 +3,19 @@ import parseCommand from './parse'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import logger from '../utils/logger'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export default function sshOptions( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  { pass, path, command, host, port, auth, knownhosts }: { [s: string]: string }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    pass, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    path, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    command, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    host, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    port, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    auth, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    knownhosts, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }: { [s: string]: string }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  key?: string | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					): string[] { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const cmd = parseCommand(command, path); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const hostChecking = (knownhosts !== '/dev/null') ? 'yes' : 'no' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const hostChecking = knownhosts !== '/dev/null' ? 'yes' : 'no'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const sshRemoteOptsBase = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    'ssh', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    host, | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -18,7 +26,7 @@ export default function sshOptions( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    `PreferredAuthentications=${auth}`, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    '-o', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    `UserKnownHostsFile=${knownhosts}`, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    '-o',  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    '-o', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    `StrictHostKeyChecking=${hostChecking}`, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  ]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  logger.info(`Authentication Type: ${auth}`); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |