Temporary OBS Credentials for a Small Cloud Server
When a small cloud server needs to upload backups or user files to OBS, do not put a long-lived Access Key and Secret Key on the server. A leaked key can be reused from anywhere until someone notices and rotates it. Temporary credentials, scoped to one bucket and one purpose, reduce that blast radius.
1. Create a dedicated agency or user for uploads only
Give the upload identity no console login and no permissions beyond OBS. For example, allow only PutObject and GetObject on one bucket path, such as backups/app/*. Deny listing other buckets and deny delete if the workload does not need it. Test with a single small file before wiring it into a backup job.
2. Issue short-lived credentials at run time
Request temporary security credentials when the job starts, use them for that job, and let them expire. A lifetime of minutes to a few hours is usually enough for a backup upload. Avoid writing the temporary token to logs, shell history, or a world-readable config file. If a job needs to run unattended, prefer an agency attached to the server over a credential stored on disk.
3. Harden the server side as well
The credential is only one layer. Keep SSH key-only login, keep fail2ban or an equivalent login guard enabled, and allow outbound traffic to OBS only where the network policy permits it. Rotate the underlying long-lived credential if it was ever copied to a workstation, shared in chat, or committed to a repository, even by accident.
4. A simple checklist before you rely on it
- One bucket, one path prefix, and only the actions the job needs.
- Short expiry, and no credential in logs or version control.
- A test upload, a test download, and a failed attempt from an out-of-scope path.
- A rotation plan for the day a credential is exposed.
Least privilege is not extra paperwork for a small server. It is the difference between a single compromised upload job and a compromised storage account.
- 点赞
- 收藏
- 关注作者
评论(0)