-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·45 lines (39 loc) · 1.38 KB
/
setup.sh
File metadata and controls
executable file
·45 lines (39 loc) · 1.38 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
#!/bin/bash
set -e
mkdir -p keys data
chown -R $(id -u):$(id -g) keys data 2>/dev/null || true
# Generate host keys only if they don't already exist
if [ ! -f keys/ssh_host_ed25519_key ]; then
echo "Generating host keys..."
ssh-keygen -t ed25519 -f keys/ssh_host_ed25519_key -N "" -C "sftp-server-ed25519"
ssh-keygen -t rsa -b 4096 -f keys/ssh_host_rsa_key -N "" -C "sftp-server-rsa"
else
echo "Host keys already exist, skipping."
fi
# Generate client key only if it doesn't already exist
if [ ! -f keys/testuser ]; then
echo "Generating client key..."
ssh-keygen -t rsa -b 4096 -f keys/testuser -N "" -C "testuser@sftp-test"
else
echo "Client key already exists, skipping."
fi
chmod 600 keys/ssh_host_ed25519_key keys/ssh_host_rsa_key keys/testuser
chmod 644 keys/ssh_host_ed25519_key.pub keys/ssh_host_rsa_key.pub keys/testuser.pub
chown -R $(id -u):$(id -g) keys 2>/dev/null || true
chmod 755 data
# Load .env defaults
SFTP_USER="${SFTP_USER:-testuser}"
SFTP_PASS="${SFTP_PASS:-testpass}"
SFTP_PORT="${SFTP_PORT:-2222}"
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
echo ""
echo "✅ Ready! Start the server with: docker compose up -d"
echo ""
echo "Connect with password:"
echo " sftp -oPort=${SFTP_PORT} ${SFTP_USER}@localhost"
echo " Password: ${SFTP_PASS}"
echo ""
echo "Connect with key:"
echo " sftp -i ./keys/testuser -oPort=${SFTP_PORT} ${SFTP_USER}@localhost"