SSH Flashcards
What is the command to install ssh?
apt-get install openssh-server
What is the command to check if the status of the ssh service?
service sshd status
systemctl status sshd.service
What is the command to start the ssh service?
service sshd start
systemctl start sshd.service
What is the command to stop the sshd service?
service sshd stop
systemctl stop sshd.service
What is the command to ssh into another machine?
ssh user@hostname
What is the command to generate public/private keys?
ssh-keygen
creates: ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
How do ssh keys work?
private and public key generated by client
private key stored on client
public key copied to desired users ~/.ssh/authorized_keys
connect to server on client ssh-add ~/.ssh/id_rsa (private)
What is the syntax to scp a file/directory to a remote machine?
scp /path/to/source user@machine:/path/to/destination
What is the command to configure sshd to run automatically on boot?
systemctl enable sshd.service
What is the command to configure sshd to not run automatically on boot?
systemctl disable sshd.service
If using an additional unique private and public key pair, what command must you run in order to ssh into the remote machine?
ssh-add ~.ssh/id_rsa_second_key
- adds the clients private key to authenticate with the clients public key stored on the remote machine
- this is for additional key pairs, this is done transparently the first time a key pair is created
What is a command to add the public key of an ssh client to the remote machine?
cat ~/.ssh/id_rsa.pub | ssh user@machine “mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat»_space; ~/.ssh/authorized_keys”
What is the command to add the public key of an ssh client to the remote machine using ssh-copy?
ssh-copy-id
What is the tmux command to create an ssh session and detach for a long running command?
tmux new-session -s
What is the tmux command to rejoin a session?
tmux attach -t