You are not logged in.

#1 2014-03-01 22:39:36

justinzane
Member
From: Weed, CA, US
Registered: 2013-07-19
Posts: 19
Website

[Solved] ArchISO: How to Enable SSH on Boot?

The goal: setup a customized ("releng") Arch ISO so that immediately on boot,

sshd

is started and there is a

/root/.ssh/authorized_keys

file in place so that one can login without using a password. I've added

openssh

to the packages.both file, and copied an

/etc/ssh/sshd_config

into

archlive/releng/root-image/etc/ssh/

. What else needs to be done?

Last edited by justinzane (2014-03-02 19:47:17)

Offline

#2 2014-03-02 00:00:40

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [Solved] ArchISO: How to Enable SSH on Boot?

The same thing to you do on your system:

systemctl enable sshd.socket

Offline

#3 2014-03-02 00:53:16

justinzane
Member
From: Weed, CA, US
Registered: 2013-07-19
Posts: 19
Website

Re: [Solved] ArchISO: How to Enable SSH on Boot?

I did the `systemctl enable sshd.service` in `archlive/releng/root-image/root/customize_root_install.sh`. Forgot to mention that. What I do not inderstand is:

- do i need to add `systemctl enable sshd.service` in `archlive/releng/root-image/root/customize_root_install.sh` so that ssh works on boot?

- what else, if anything, do i need to copy to `archlive/releng/root-image/etc/ssh/`?

- where do I put the `authorized_keys` file?

- what needs to go in `archlive/releng/root-image/etc/netctl/`, if anything, so that I can be sure that the system will autoconnect to any wired interface using dhcp?
    - autoconnect to any open 802.11 network on boot?
    - autoconnect to a specific netctl.profile on boot?

- anything else to ensure that, assuming the system boots from the CustomArchLive media, no direct input is needed -- everything beyond boot is able to be done via ssh?

Last edited by justinzane (2014-03-02 00:54:56)

Offline

#4 2014-03-02 01:58:19

justinzane
Member
From: Weed, CA, US
Registered: 2013-07-19
Posts: 19
Website

Re: [Solved] ArchISO: How to Enable SSH on Boot?

djgera wrote:

The same thing to you do on your system:

systemctl enable sshd.socket

Unfortunately, that does not work...

### root-image/root/customize_root_image.sh
...
systemctl enable multi-user.target pacman-init.service choose-mirror.service 
systemctl enable netctl.service
systemctl start netctl.service
netctl enable wired_dhcp
netctl enable wireless-ZANE
netctl start wired_dhcp
netctl start wireless-ZANE
systemctl enable sshd.service 
systemctl start sshd.service

end up with the following messages:

Generation complete.
ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
ln -s '/etc/systemd/system/pacman-init.service' '/etc/systemd/system/multi-user.target.wants/pacman-init.service'
ln -s '/etc/systemd/system/choose-mirror.service' '/etc/systemd/system/multi-user.target.wants/choose-mirror.service'
ln -s '/usr/lib/systemd/system/netctl.service' '/etc/systemd/system/multi-user.target.wants/netctl.service'
Running in chroot, ignoring request.
en-any: using interface enp9s0
ln -s '/etc/systemd/system/netctl@wired_dhcp.service' '/etc/systemd/system/multi-user.target.wants/netctl@wired_dhcp.service'
Running in chroot, ignoring request.
wl-any: using interface wlp7s0
ln -s '/etc/systemd/system/netctl@wireless\x2dZANE.service' '/etc/systemd/system/multi-user.target.wants/netctl@wireless\x2dZANE.service'
Running in chroot, ignoring request.
Running in chroot, ignoring request.
Running in chroot, ignoring request.
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'
Running in chroot, ignoring request.

So, how does one convince systemctl to work in chroot?

Offline

#5 2014-03-02 02:56:37

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Solved] ArchISO: How to Enable SSH on Boot?

I'm sure you could probably manually make the symlink in releng/root-image/etc/systemd/system.

Offline

#6 2014-03-02 03:01:39

justinzane
Member
From: Weed, CA, US
Registered: 2013-07-19
Posts: 19
Website

Re: [Solved] ArchISO: How to Enable SSH on Boot?

Apologies to djgera... It does. Just need to remove the "start" lines.

justinzane wrote:

Unfortunately, that does not work...

### root-image/root/customize_root_image.sh
...
systemctl enable multi-user.target pacman-init.service choose-mirror.service 
systemctl enable netctl.service
[del]systemctl start netctl.service[/del]
netctl enable wired_dhcp
netctl enable wireless-ZANE
[del]netctl start wired_dhcp[/del]
[del]netctl start wireless-ZANE[/del]
systemctl enable sshd.service 
[del]systemctl start sshd.service[/del]

The only other fix needed is to put the

.ssh/authorized_keys

into

archlive/releng/root-image/etc/skel/

since that is apparently the only way to get files into the subsequent /root/ user directory.

Offline

#7 2014-03-02 03:04:45

justinzane
Member
From: Weed, CA, US
Registered: 2013-07-19
Posts: 19
Website

Re: [Solved] ArchISO: How to Enable SSH on Boot?

WonderWoofy wrote:

I'm sure you could probably manually make the symlink in releng/root-image/etc/systemd/system.

Thanks, but I was just reading without care. The `systemctl enable ...` lines work. It was the `systemctl start ...` lines that failed. And, once I tested the resulting USB stick, I had an IP address and a working ssh daemon.

Offline

#8 2014-03-02 05:38:55

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [Solved] ArchISO: How to Enable SSH on Boot?

Please mark this thread as solved.

Offline

#9 2014-08-02 04:59:04

iliveinapark
Member
Registered: 2013-03-18
Posts: 33

Re: [Solved] ArchISO: How to Enable SSH on Boot?

Just wanted to add a comment for anyone else trying to do this.

If you want to be able to log in without adding your public key to the archiso, you can enable login with an empty password (the default root password on archiso):

# mkdir airootfs/ssh
# cp /etc/ssh/sshd_config airootfs/etc/ssh/
# <editor> airootfs/etc/ssh/sshd_config

Uncomment and set to yes the following settings:

PasswordAuthentication yes
PermitEmptyPasswords yes

Offline

Board footer

Powered by FluxBB