SSH Flashcards

1
Q

What is the command to install ssh?

A

apt-get install openssh-server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the command to check if the status of the ssh service?

A

service sshd status

systemctl status sshd.service

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the command to start the ssh service?

A

service sshd start

systemctl start sshd.service

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the command to stop the sshd service?

A

service sshd stop

systemctl stop sshd.service

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the command to ssh into another machine?

A

ssh user@hostname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the command to generate public/private keys?

A

ssh-keygen

creates: ~/.ssh/id_rsa ~/.ssh/id_rsa.pub

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do ssh keys work?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the syntax to scp a file/directory to a remote machine?

A

scp /path/to/source user@machine:/path/to/destination

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the command to configure sshd to run automatically on boot?

A

systemctl enable sshd.service

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the command to configure sshd to not run automatically on boot?

A

systemctl disable sshd.service

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If using an additional unique private and public key pair, what command must you run in order to ssh into the remote machine?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a command to add the public key of an ssh client to the remote machine?

A

cat ~/.ssh/id_rsa.pub | ssh user@machine “mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat&raquo_space; ~/.ssh/authorized_keys”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the command to add the public key of an ssh client to the remote machine using ssh-copy?

A

ssh-copy-id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the tmux command to create an ssh session and detach for a long running command?

A

tmux new-session -s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the tmux command to rejoin a session?

A

tmux attach -t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the shortcut to send commands to tmux?

A
ctrl + b
c - new window
, - rename window
d - detach session
w - list windows
17
Q

What is the tmux command to list sessions?

A

tmux list-sessions

18
Q

What is the tmux command to kill sessions?

A

tmux kill-session -t

19
Q

What us the tmux command to kill all sessions?

A

tmux kill-server

20
Q

If ssh-add fails how can you resolve this?

A

eval ssh-agent -s
or
eval “$(ssh-agent)”
Loads ssh-agent environment variables into environment

21
Q

How do you specify the private key to use if ssh is being denied?

A

ssh user@machine -i /path/to/privatekey