Differences
This shows you the differences between two versions of the page.
— | ssh [2019/01/04 23:07] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Secure Shell (SSH) ====== | ||
+ | * [[dropbear]] | ||
+ | * [[OpenSSH]] | ||
+ | * [[ssh-keygen]] | ||
+ | |||
+ | === Managing Keys === | ||
+ | |||
+ | You can have as many public keys as you like. When using ssh, you can specify which one to use if it is a non-standard name (id_rsa, id_dsa) using '' | ||
+ | |||
+ | You can see which keys are authorized to login by looking at '' | ||
+ | |||
+ | === Key Generation === | ||
+ | |||
+ | Open a terminal and run this command to create a new key. You can pick from two encryption methods: RSA or DSA. | ||
+ | |||
+ | < | ||
+ | |||
+ | Follow the prompts. | ||
+ | |||
+ | Once finished your private and public key will be in '' | ||
+ | |||
+ | Your private key will be named '' | ||
+ | |||
+ | === Uploading a Public Key === | ||
+ | |||
+ | If you have password-based authentication available on a server, there is a simple way to copy your public key over to allow key-based authentication. | ||
+ | |||
+ | < | ||
+ | |||
+ | This will automatically create the '' | ||
+ | |||
+ | Otherwise, make sure the permissions are set correctly. | ||
+ | ==== Configuration ==== | ||
+ | |||
+ | You can modify your configuration file for SSH to simplify connections. | ||
+ | |||
+ | Say, for example, you wanted to connect to a server on a non-standard port, without a DNS name. A terminal command might look like this: | ||
+ | |||
+ | < | ||
+ | |||
+ | You can put all these custom settings in '' | ||
+ | |||
+ | < | ||
+ | Host seekrit-server | ||
+ | User dumont | ||
+ | HostName 192.168.15.79 | ||
+ | Port 9822 | ||
+ | </ | ||
+ | |||
+ | Then your command would be this: | ||
+ | |||
+ | < | ||
+ | |||
+ | This would also work with any SFTP clients as well. | ||
+ | |||
+ | ==== JumpBox ==== | ||
+ | |||
+ | You can jump through another box to SSH into a second one (and third, fourth, etc.): | ||
+ | |||
+ | < | ||
+ | ssh -J jumpbox.beandog.org dest.beandog.org | ||
+ | </ | ||
+ | |||
+ | ==== Notes ==== | ||
+ | |||
+ | Setup rate-limiting in the firewall so users can only attempt a connection every certain number of times per minute. | ||
+ | |||
+ | * [[https:// | ||
+ | |||
+ | < | ||
+ | iptables -N rate-limit | ||
+ | iptables -A rate-limit -p tcp -m conntrack --ctstate NEW -m limit --limit 3/min --limit-burst 3 -j RETURN | ||
+ | iptables -A rate-limit -j DROP | ||
+ | iptables -I INPUT 1 -p tcp --dport 22 -j rate-limit | ||
+ | </ | ||
+ | |||
+ | ==== Gotchas ==== | ||
+ | |||
+ | ** Running '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | < | ||
+ | ssh < /dev/null | ||
+ | </ |