What we do?
- Generate the New SSH Key
- Copy the Public Key to the Server
- Configure the SSH Client
- Test the Connection
At a glance to see Diagram
To Do
1. Generate the New SSH Key (whithout passphrase)
ssh-keygen -t ed25519 -f ~/.ssh/id_rsa_deploy -N ""
2. Copy the Public Key to the Server
ssh-copy-id -i ~/.ssh/id_rsa_deploy.pub server-user@server-ip
- Configure the SSH Client
Host deploy-server
HostName server-ip
User server-user
IdentityFile ~/.ssh/id_rsa_deploy
IdentitiesOnly yes
- Test the Connection
ssh deploy-server
(Important): Fix permissions (if SSH refuses key)
Run these on your deployment machine:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/deploy_key
chmod 644 ~/.ssh/deploy_key.pub
chmod 600 ~/.ssh/config
⭐ Bonus Point:
Securely copy file/folder from local to server
File copy from local to server:
scp file_name server_name_prod:/path_of_target_directory
// Example
scp index.html server_name1:/var/www/app1
Folder copy from local to server:
scp -r ./dist/* server_name_prod:/path_of_target_directory

Top comments (0)