All Projects → FernandoMiguel → Sshremotekeys

FernandoMiguel / Sshremotekeys

Licence: mit
Managing SSH keys remotely to control access to hosts

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Sshremotekeys

Module Security Public
The public documentation for the gruntwork-io/module-security repo, which contains packages for setting up best practices for managing secrets, credentials, and servers
Stars: ✭ 67 (-4.29%)
Mutual labels:  aws, ssh
Cashier
A self-service CA for OpenSSH
Stars: ✭ 590 (+742.86%)
Mutual labels:  ssh, ssh-key
Ssh Permit A38
Central management and deployment for SSH keys
Stars: ✭ 451 (+544.29%)
Mutual labels:  ssh, ssh-key
Geofront
Simple SSH key management service
Stars: ✭ 337 (+381.43%)
Mutual labels:  ssh, ssh-key
Ssh Agent Helper
Use SSH keys from CMD, PowerShell, etc. on Windows
Stars: ✭ 31 (-55.71%)
Mutual labels:  ssh, ssh-key
Bridgy
cloud inventory + ssh + tmux + sshfs
Stars: ✭ 374 (+434.29%)
Mutual labels:  aws, ssh
Simpleremote
Remote Administration Tools
Stars: ✭ 504 (+620%)
Mutual labels:  ssh, remote
gpu-monitor
Script to remotely check GPU servers for free GPUs
Stars: ✭ 85 (+21.43%)
Mutual labels:  ssh, remote
Geofront Cli
It provides a CLI client for Geofront, a simple SSH key management server.
Stars: ✭ 30 (-57.14%)
Mutual labels:  ssh, ssh-key
Aws Ec2 Ssh
Manage AWS EC2 SSH access with IAM
Stars: ✭ 796 (+1037.14%)
Mutual labels:  aws, ssh
Aws Gate
Better AWS SSM Session manager CLI client
Stars: ✭ 294 (+320%)
Mutual labels:  aws, ssh
Ec2connect
Stars: ✭ 53 (-24.29%)
Mutual labels:  aws, ssh
Sync
syncs your local folder with remote folder using scp
Stars: ✭ 293 (+318.57%)
Mutual labels:  ssh, remote
Bastillion Ec2
A web-based SSH console to execute commands and manage multiple EC2 instances simultaneously running on Amazon Web Services (AWS).
Stars: ✭ 410 (+485.71%)
Mutual labels:  aws, ssh
Ssh Vault
🌰 encrypt/decrypt using ssh keys
Stars: ✭ 277 (+295.71%)
Mutual labels:  ssh, ssh-key
Gbt
Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go.
Stars: ✭ 457 (+552.86%)
Mutual labels:  aws, ssh
wsl-agent-bridge
WSL compatibility bridge for ssh-agent on Windows
Stars: ✭ 17 (-75.71%)
Mutual labels:  ssh, ssh-key
re-mote
Re-mote operations using SSH and Re-gent
Stars: ✭ 61 (-12.86%)
Mutual labels:  ssh, remote
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+1025.71%)
Mutual labels:  aws, ssh
Xiringuito
SSH-based "VPN for poors"
Stars: ✭ 969 (+1284.29%)
Mutual labels:  aws, ssh

SSH with Remote Keys storage

With my sysadmin background, being as lazy as possible, I always try to have the lowest overhead maintenance possible over systems.

Securely maintain ssh keys to access servers is a tricky business. Keys have to be rotated regularly, individuals join/leave projects/companies, ssh key passwords are forgotten, etc.

Typically, admins add ssh keys to ~/.ssh/authorized_keys or %h/.ssh/authorized_keys, others LDAP.

Updating these is a nightmare, even with packaging tools like ansile or puppet.

Some have crons to update these, but that can create a delay, and we all know what happens when you add delays.

Instead, I've opted to move away from managing keys in the instances, and move them to a centrally controlled location, where it is easy to update objects/permissions and have the instances check back on login attempt.

Installation

sshauth-install.sh needs to be run in the instance.

It can be executed at anytime, or ideally during the creation of the instance. When deploying AWS instances, you can pass this with UserData

You will need to modify [https://s3.amazonaws.com/BUCKET/userkeys.sh] to use your server personalised version.

The script will modify ssh_config, pull your custom userkeys.sh, and restart sshd.

Usage

SSH AuthorizedKeysCommand was introduced in 2013's OpenSSH 6.1, although you will only find is commonly around in OpenSSH 6.9 distro packages.

From the manual:

sshd(8): Added a sshd_config(5) option AuthorizedKeysCommand to support fetching authorized_keys from a command in addition to (or instead of) from the filesystem. The command is run under an account specified by an AuthorizedKeysCommandUser sshd_config(5) option.

This allows us to execute an arbitary command when a login attemp it made via ssh. In the case of this setup, it executes userkeys.sh

Depending on wether you are curling github API for keys [https://github.com/USER.keys] (for individual devs or extremelly small teams) or a s3 bucket object (one object per set of permissions), you will need to create your custom userkeys.sh.

When there's an attempt login via ssh, sshd will execute userkeys.sh, which will then curl a file for ssh public keys, and match that against the one provided during login.

You can use Match User or Match Group to parse public keys against logins, but while increasing security, it also increases overhead.

Gotchas

Ed25519

ssh public key historicly have been created with RSA algorithm. But like everytghing in tech, that's old by today's standards.

The new shiny algorithm is Ed25519. It uses a Diffie-Hellman elliptic-curve, allowing it to be much smaller than tradicional RSA keys. Where a good RSA key starts in 2048 bits, an Ed25519 is just 256.

Combine that with the easeness of reading, storing, curl them, you got a winner.

To generate one, run $ ssh-keygen -t ed25519 with as many rounds as you see fit, and don't forget to password-protect it.

Copy the contents of its public key to GitHub key settings or your project permission object, and you are ready to go.

Fail2Ban and general security

Please setup your instance with Fail2Ban, to prevent anyone from hammering your ssh port.

Also disable root PermitRootLogin no and disable passwords PasswordAuthentication no.

[sshauth-install.sh] already adds AuthenticationMethods publickey to /etc/ssh/sshd_config

API rate limit

When curling against Internet webservices, developers need to account with services rate limits, in place to prevent abuse.

GitHub API rate limit is of 60 requests per hour for unauthenticated requests, and 5000 when used with OAuth.

An AWS s3 bucket as a limit of 800 GET requests per second.

Cache

If you have many devs login into a server or even bot scanning (hence Fail2Ban), your host can easily reach the limit and prevent you from legitimately accessing your server.

To minimise this, the response of the external request (either Github or AWS) is saved to the file $HOME/.ssh/ak_cache and cached for 5 minutes.

Future Improvements

Right now, we are querying GitHub user profiles for sshkeys.

An advanced process can probably be developed using GitHub GraphQL API to queries Teams instead of users, allowing further control over Projects access

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].