Enable SSH on Raspberry Pi raspberry pi os lite (64-bit)
Raspberry-Pi-ssh-server-part1
We have prepared this guide to teach you how SSH can be enabled and configured on Debian 12.
I FINALLY received a 27W power supply yesterday and thought I would use it to fire up an RPi 5. Igave the same host name as the RP4 I used previously, flashed the image and switched it on and tried to ssh into the pi.
Raspberry Pi SSH is disabled by default
n November 2016, SSH was disabled by default on Raspbian. This move was made to prevent Raspberry Pi devices from potentially becoming a part of an IoT botnet.
If you installed any of the Raspbian versions from late 2016 onwards, then SSH is disabled by default. The reason behind this decision was to improve security. Since all Raspbian images come with a user “pi” and the default password “raspberry,” it was easy for hackers to use this in their favor.
user “pi” is detleted by default.
If you installed any of the Raspbian versions from late 2020 debain 11 Bullseye onwards, then user “pi” is detleted by default.
2022年4月7日,树莓派官方发布新闻称,出于系统安全考虑,目前最新的树莓派系统「Raspberry Pi OS Bullseye」已经移除了默认账户「Pi」,用户需要在首次启动树莓派系统时设置账号和密码,才能进入树莓派系统。这意味着,我们在设置账号密码前无法远程进入树莓派系统了。
Raspberry Pi uses UK keyboard layout by default.
step 1.Enable SSH Server on Raspberry Pi
Enable SSH on Raspberry Pi in Headless Mode - debain 10,9, ...
Enable SSH on Raspberry Pi using GUI Configuration Options
Enabling SSH with raspi-config
step 2.Enable Raspberry local root Login
Change a new password for root login
unlock the root account
step 3.Enable Raspberry ssh client root Login
PermitRootLogin yes
/etc/ssh/sshd_config
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/bin:/usr/games
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Include /etc/ssh/sshd_config.d/*.conf
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes #new
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 #new
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
# PermitRootLogin prohibit-password # old
PasswordAuthentication yes #new
#PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
KbdInteractiveAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
step 5.Enable Raspberry ssh client use Password Authentication
修改/etc/ssh/sshd-config文件.
将其中的PermitRootLogin no修改为yes
PubkeyAuthentication yes修改为no
AuthorizedKeysFile .ssh/authorized_keys前面加上#屏蔽掉,
PasswordAuthentication no修改为yes就可以了。
step 4.Test the SSH Server on Debian 12
ssh 127.0.0.1
debug
ssh -v [email protected]
Secure Shell (SSH)
1. Change the Default SSH Port
2. Enhance Linux SSH Security Using Key Pairs
3. Disable Server SSH Root Login
4. Disable Password-Based Logins on Your Server
5. Restrict SSH Access Using iptables
https://phoenixnap.com/kb/linux-ssh-security
Comments
Comments are closed