SSH
Useage
$ ssh <username>@<host-ip>
Keys
Courtesty of stackexchange
Generating a Key Pair the Proper way
- On Local server
ssh-keygen -t rsa
- On remote Server
ssh root@remote_servers_ip "mkdir -p .ssh"
- Uploading Generated Public Keys to the Remote Server
cat ~/.ssh/id_rsa.pub | ssh root@remote_servers_ip "cat >> ~/.ssh/authorized_keys"
- Set Permissions on Remote server
ssh root@remote_servers_ip "chmod 700 ~/.ssh; chmod 640 ~/.ssh/authorized_keys"
- Login
ssh root@remote_servers_ip
- Enabling SSH Protocol v2
uncomment "Protocol 2" in /etc/ssh/sshd_config
- Enabling public key authorization in sshd
uncomment "PubkeyAuthentication yes" in /etc/ssh/sshd_config
- If StrictModes is set to yes in /etc/ssh/sshd_config then
restorecon -Rv ~/.ssh
If you get "The program 'restorecon' is currently not installed. You can install it by typing"
sudo apt install policycoreutils
...then run that
Over Two ssh Hops
ssh from systemA trough systemB into systemC:
$ ssh -t user1@systemB "ssh user2@systemC"
Mount file system under similar circumstances: