Basics for setting up SSH on a server and on your laptop or other machine that you want to use to SSH into the server. I set up SSH, and talk about how to set up SSH keys and a config file.
NOTE: at one point in the video I say that every server has its own authorized_keys file, what I should have said was "every user on the server has their own authorized_keys file". So for each user that exists on the server, you can add SSH keys that are authorized to sign in as that user on that server.
Steps:
1. On the server, set up the ssh server
sudo apt update
sudo apt install openssh-server
sudo systemctl status ssh (should say it's running)
sudo ufw allow ssh (on ubuntu, this modifies the ubuntu firewall to allow ssh)
2. On the client, try to ssh for a user that you know the password for
ssh username@ipAddress
ssh username@ipAddress -p portNumber (if port is needed, which it will be for vm)
it'll ask for the user's password, then you're in
3. Set up ssh key on the client if you don't have one already
cat ~/.ssh/id_rsa.pub (to see if you have one)
ssh-keygen -t rsa -b 4096 (to generate one)
4. Copy the public ssh key to the server for the right user
NOTE: each user on the server has its own authorized_keys file, and each line on the file is one ssh key. Blank lines and lines that start with # are ignored
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 5679 username@ipAddress
omit the port if you don't need it
another option is to use scp:
scp -P 5679 ~/.ssh/id_rsa.pub username@ipAddress:~/.ssh
5. Now you can ssh to the server without it asking for your password
6. If you want to disable password ssh
sudo nano /etc/ssh/sshd_config
Add these 2 lines (make sure there are no typos) then save and exit
PasswordAuthentication no
ChallengeResponseAuthentication no
restart the ssh daemon
sudo systemctl restart sshd
7. Now you can only ssh in via ssh keys, no password ssh will be allowed
Watch video Setting up SSH Basics online, duration hours minute second in high quality that is uploaded to the channel Loren Pabst 26 February 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 25 times and liked it 0 visitors.