-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsetup-ssh-deploy.sh
More file actions
executable file
·62 lines (54 loc) · 1.62 KB
/
setup-ssh-deploy.sh
File metadata and controls
executable file
·62 lines (54 loc) · 1.62 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# SSH Deploy Key Setup Script
# This script helps configure SSH key-based authentication for deployments
set -e
echo "=== SSH Deploy Key Setup ==="
echo
# Check if SSH key already exists
SSH_KEY_PATH="$HOME/.ssh/deploy"
if [ -f "$SSH_KEY_PATH" ]; then
echo "✅ SSH key already exists at $SSH_KEY_PATH"
else
echo "Generating SSH key..."
mkdir -p "$HOME/.ssh"
ssh-keygen -t ed25519 -f "$SSH_KEY_PATH" -N "" -C "deploy@$(hostname)"
chmod 600 "$SSH_KEY_PATH"
chmod 644 "$SSH_KEY_PATH.pub"
echo "✅ SSH key generated at $SSH_KEY_PATH"
fi
echo
echo "Public key content (add this to your server's ~/.ssh/authorized_keys):"
echo "---"
cat "$SSH_KEY_PATH.pub"
echo "---"
echo
# Create .env.deploy if it doesn't exist
if [ ! -f ".env.deploy" ]; then
echo "Creating .env.deploy configuration file..."
cat > .env.deploy << 'EOF'
# Deployment Configuration
DEPLOY_SERVER=szentiras.eu
DEPLOY_PORT=22
DEPLOY_USER=deploy
DEPLOY_REMOTE_PATH=/tmp/
SSH_KEY_PATH=~/.ssh/deploy
EOF
echo "✅ Created .env.deploy"
echo
echo "⚠️ Please update .env.deploy with your actual deployment details:"
cat .env.deploy
else
echo "✅ .env.deploy already exists"
fi
echo
echo "=== Next Steps ==="
echo "1. Copy the public key above and add it to your server:"
echo " ssh deploy@szentiras.eu 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'"
echo " (Then paste the public key content)"
echo
echo "2. Test the connection:"
echo " ssh -i $SSH_KEY_PATH -p 22 deploy@szentiras.eu 'echo SSH works!'"
echo
echo "3. Once verified, you can run deployments without password prompts:"
echo " ./deploy-prod.sh"
echo