Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 4763  / 1 Year ago, fri, december 30, 2022, 9:17:40

I want to install Ubuntu Server 20.04 on Rpi 4 without monitor, so I have to setup SSH in advance by editing user-data file in system-boot folder.


Is it possible to setup SSH for user: set public key and disable password by default before the first login to my Pi?


I found one manual here but there is no info how to setup SSH properly in uaer-data file:


chpasswd:
expire: true
list:
- ubuntu:ubuntu

I need help as I can't find any comprehensive example for such purpose, unfortunately. But there are some cloud config examples for virtual box (1, 2), so I don't know if it is valid for my case.


users:
- default
- name: ubuntu
ssh-authorized-keys:
- <your user public key here>
sudo: ALL=(ALL) NOPASSWD:ALL
groups: sudo
shell: /bin/bash

More From » server

 Answers
7

Folks, after several attempts installing Ubuntu w/o monitor (playing with blackbox) the required config was succeeded.


My user-data file:


users:
- default
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: sudo, users, admin
lock_passwd: true
ssh_pwauth: True
ssh_import_id: None
ssh_authorized_keys:
- <your user public key here>

#chpasswd:
# expire: true
# list:
# - ubuntu:ubuntu

#ssh_pwauth: true

Note that default chpasswd and ssh_pwauth are commented out and ssh_authorized_keys written with underscores unlike many examples.


So, you have to generate SSH key on your machine and add it to ssh_authorized_keys list, that's all. No twitching after first connection is required.


[#2169] Sunday, January 1, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
untroo

Total Points: 3
Total Questions: 110
Total Answers: 95

Location: Palestine
Member since Thu, Oct 28, 2021
3 Years ago
;