-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (39 loc) · 1.6 KB
/
Makefile
File metadata and controls
46 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.PHONY: all openssh keys config build clean
OPENSSH_VERSION ?= v8.1.0.0p1-Beta
OPENSSH_URL ?= https://github.com/PowerShell/Win32-OpenSSH/releases/download/$(OPENSSH_VERSION)/OpenSSH-Win64.zip
SSH_KEY_DIR ?= $(HOME)/.ssh
TARGET ?= WinSSH.exe
all: openssh keys config build
openssh:
@echo "[*] Downloading OpenSSH..."
@if ! curl -fsL $(OPENSSH_URL) -o OpenSSH-Win64.zip; then \
echo "[!] Error downloading OpenSSH"; \
exit 1; \
fi
@if ! unzip -q OpenSSH-Win64.zip; then \
echo "[!] Error extracting OpenSSH"; \
exit 1; \
fi
@mv OpenSSH-Win64/sshd.exe ./ || (echo "[!] Error moving sshd.exe"; exit 1)
@rm -rf OpenSSH-Win64.zip OpenSSH-Win64
keys:
@echo "[*] Generating SSH keys..."
@if [ ! -f "$(SSH_KEY_DIR)/id_rsa" ] || [ ! -f "$(SSH_KEY_DIR)/id_rsa.pub" ]; then \
ssh-keygen -t rsa -b 4096 -f "$(SSH_KEY_DIR)/id_rsa" -q -N ""; \
fi
@cp "$(SSH_KEY_DIR)/id_rsa" ssh_host_rsa_key || (echo "[!] Error copying private key"; exit 1)
@cp "$(SSH_KEY_DIR)/id_rsa.pub" authorized_keys || (echo "[!] Error copying public key"; exit 1)
config:
@echo "[*] Creating sshd_config file"
@printf "PasswordAuthentication no\nPubkeyAuthentication yes\nPermitEmptyPasswords no\nChallengeResponseAuthentication no\nForceCommand powershell.exe\n" > sshd_config
build:
@echo "[*] Building..."
@if ! GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o $(TARGET) main.go; then \
echo "[!] Error building"; \
exit 1; \
fi
@echo "[*] Built: $(TARGET)"
@rm -f ssh_host_rsa_key authorized_keys sshd_config sshd.exe
clean:
@echo "[*] Cleaning up..."
@rm -f $(TARGET) ssh_host_rsa_key authorized_keys sshd_config sshd.exe