Skip to content

Commit

Permalink
init: init project
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayouuuu committed Jul 5, 2022
0 parents commit 6c2ba9a
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:18.04

LABEL "com.github.actions.name"="ssh-socks-action"
LABEL "com.github.actions.description"="Setup ssh socks5 proxy that use proxy-connect"
LABEL "com.github.actions.icon"="code"
LABEL "com.github.actions.color"="black"

RUN apt-get update && apt-get install -y sshpass connect-proxy

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 GitHub Actions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Example usage

```yaml
- name: socks ssh action
uses: Ayouuuu/ssh-socks-action
with:
proxy_username: ${{ secrets.USER_NAME }}
proxy_server: ${{ secrets.SERVER }}
proxy_port: ${{ secrets.PORT }}
proxy_socks5_pwd: ${{ secrets.SOCKS5_PWD }}
host: 114.112.113.221
port: 32200
username: 'root'
key: ${{ secrets.KEY }}
run: |
ls
whoami
```
50 changes: 50 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'ssh-socks-action'
description: 'Setup ssh socks5 proxy that use proxy-connect'
inputs:
proxy_username:
description: 'username'
required: true
proxy_server:
description: 'your server host or ip address'
required: true
proxy_port:
description: 'server port'
required: true
proxy_socks5_pwd:
description: 'socks5 protocol user password'
required: false
username:
description: 'ssh username'
required: true
default: 'root'
host:
description: 'ssh host or ip address'
required: true
port:
description: 'ssh port'
required: true
default: '21'
password:
description: 'ssh password'
required: true
key:
description: "ssh key"
required: false
run:
description: 'commands to run'
required: false
default: 'whoami'
runs:
using: 'docker'
image: 'Dockerfile'
env:
PROXY_SERVER: ${{ inputs.proxy_server }}
PROXY_PROT: ${{ inputs.proxy_port }}
PROXY_SOCKS5_PWD: ${{ inputs.proxy_socks5_pwd }}
PROXY_USERNAME: ${{ inputs.proxy_username }}
RUN: ${{ inputs.run }}
KEY: ${{ inputs.key }}
USERNAME: ${{ inputs.username }}
PASSWORD: ${{ inputs.password }}
PORT: ${{ inputs.port }}
HOST: ${{ inputs.host }}
46 changes: 46 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh -l

set -e

echo "#################################################"
echo "Starting ${GITHUB_WORKFLOW}:${GITHUB_ACTION}"

#env
#echo "INPUT_SERVER : ${INPUT_PROXY_SERVER}"
#echo "INPUT_USERNAME : ${INPUT_PROXY_USERNAME}"
#echo "INPUT_PORT: ${INPUT_PROXY_PORT}"
#echo "INPUT_SOCKS5_PWD: ${INPUT_PROXY_SOCKS5_PWD}"
#echo "INPUT_KEY: ${INPUT_KEY}"
#echo "INPUT_RUN: ${INPUT_RUN}"
#echo "INPUT_SSH_HOST": "${INPUT_HOST}"
#echo "INPUT_SSH_PORT": "${INPUT_PORT}"
#echo "INPUT_SSH_USERNAME: ${INPUT_USERNAME}"
#echo "INPUT_SSH_PASSWORD": "${INPUT_PASSWORD}"

CMD=`echo $INPUT_RUN | sed "s/ / %% /g"`

mkdir "/root/.ssh"

export SOCKS5_PASSWD=${INPUT_SOCKS5_PWD}
config='/root/.ssh/config'
echo "Host ${INPUT_HOST}" > $config
echo " User ${INPUT_USERNAME}" >> $config
echo " Port ${INPUT_PORT}" >> $config
echo " ProxyCommand connect -S ${INPUT_PROXY_USERNAME}@${INPUT_PROXY_SERVER}:${INPUT_PROXY_PORT} %h %p" >> $config

if [ -z "$INPUT_KEY" ]
then
echo 'Using password'
export SSHPASS=$PASS
echo "sshpass -e ssh $INPUT_HOST "$CMD""
else
echo 'Using private key'
echo "$INPUT_KEY" > "/root/.ssh/id_rsa"
chmod 400 "/root/.ssh/id_rsa"

echo " IdentityFile /root/.ssh/id_rsa" >> $config
cat "/root/.ssh/config"

# ls -lha "/root/.ssh/"
echo "sshpass ssh $INPUT_HOST "$CMD""
fi

0 comments on commit 6c2ba9a

Please sign in to comment.