Difference between revisions of "Install from SSH"

From ArchWiki
Jump to: navigation, search
m (nouns are more appropriate for titles)
 
(104 intermediate revisions by 32 users not shown)
Line 1: Line 1:
==Intro==
+
[[Category:Installation process]]
This article is intended to show users how to install Arch remotely via an SSH connection. Consider this approach over the standard one in scenarios such the following:
+
[[Category:Secure Shell]]
 +
[[cs:Install from SSH]]
 +
[[es:Install from SSH]]
 +
[[it:Install from SSH]]
 +
[[ja:SSH からインストール]]
 +
[[pt:Install from SSH]]
 +
[[ru:Install from SSH]]
 +
[[zh-hans:Install from SSH]]
 +
{{Move|Installation via SSH|Sounds better.}}
 +
This article is intended to show users how to install Arch remotely via an [[SSH]] connection. Consider this approach over the standard one in scenarios such as the following:
  
Setting up Arch on...
+
* Home theater PC without a proper monitor (e.g. an SDTV);
*HTPC without a proper monitor (i.e. an SDTV).
+
* PC located in another city, state, country (friend's house, parent's house, etc.);
*A PC located in another city, state, country.
+
* PC that you would rather setup remotely, for example from the comfort of one's own workstation with copy/paste abilities from the ArchWiki.
*A PC that you would rather setup remotely, for example from the comfort of one's own workstation with copy/paste abilities from the Arch Wiki.
 
  
{{Note|The first two steps require physical access to the machine.  Obviously, if physically located elsewhere, this will need to be coordinated with another person!}}
+
== On the remote (target) machine ==
  
== Boot from Media==
+
{{Note|These steps require physical access to the machine. Obviously, if physically located elsewhere, this will need to be coordinated with another person.}}
Boot into a live Arch environment via the [[https://wiki.archlinux.org/index.php/Beginners%27_Guide#Step_1:_Obtain_the_latest_Installation_media live CD/USB image]] and log in as '''root'''.
 
  
== Setup the Live Environment to use SSH ==
+
Boot the target machine into a live Arch environment via the [[Getting and installing Arch|Live CD/USB image]]: this will log the user in as root.
One should be presented with the root prompt '''[root@archiso ~]#''' at this point.
 
  
Firstly, setup the network on the target machine:
+
At this point, setup the network on the target machine as for example suggested in [[Installation guide#Connect to the Internet]].
aif -partial-configure-network
 
  
Secondly, sync the live environment to a mirror, install the openssh package, and start it:
+
Secondly, setup a root password which is needed for an SSH connection, since the default Arch password for root is empty:
pacman -Syy
 
pacman -S openssh
 
/etc/rc.d/sshd start
 
  
{{Note|Depending on the age of the install media, pacman may complain that '''it''' should be upgraded first. Since the goal is to simply install the openssh package, it s recommended to deny this request and simply install the single package.}}
+
  # passwd
  
<pre># pacman -S  openssh
+
Now check that {{ic|PermitRootLogin yes}} is present (and uncommented) in {{ic|/etc/ssh/sshd_config}}. This setting allows root login with password authentication on the SSH server.
:: The following packages should be upgraded first :
 
    pacman 
 
:: Do you want to cancel the current operation
 
:: and upgrade these packages now? [Y/n] n</pre>
 
  
Finally, allow sshd connections and setup a root password which is needed for an ssh connection; the default arch password for root is empty.
+
{{Note|If the target machine is behind a NAT router, the SSH port (22 by default) will obviously need to be forwarded to the target machine's LAN IP address. The use of port forwarding is not covered in this guide.}}
  
echo "sshd: ALL" >> /etc/hosts.allow
+
Finally, [[start]] the openssh daemon with {{ic|sshd.service}}, which is included by default on the live CD.
passwd
 
  
== Connect to the Target PC via SSH ==
+
{{Note|After installation it is recommended to harden SSH. The first step would be to remove {{ic|PermitRootLogin yes}} from {{ic|/etc/ssh/sshd_config}}.}}
Connect to the target machine via the following command:
 
$ ssh root@ip.address.of.target
 
  
From here one is presented with live environment's the welcome message and is able to administer the target machine as-if sitting at the physical keyboard.
+
== On the local machine ==
  
<pre>$ ssh root@10.1.10.105
+
On the local machine, connect to the target machine via SSH with the following command:
root@10.1.10.105's password:
 
Last login: Thu Dec 23 08:33:02 2010 from 10.1.10.200
 
**************************************************************
 
* To begin installation, run /arch/setup                    *
 
* You can find documentation at                              *
 
*  /usr/share/aif/docs/official_installation_guide_en        *
 
*                                                            *
 
* i18n: Use the 'km' utility to change your keyboard layout  *
 
*      and console font.                                    *
 
*                                                            *
 
* If you are looking to install Arch on something more      *
 
* exotic, such as your kerosene-powered cheese grater,      *
 
* please consult http://wiki.archlinux.org.                  *
 
*                                                            *
 
**************************************************************
 
[root@archiso ~]#</pre>
 
  
==Next Steps==
+
$ ssh root@''ip.address.of.target''
The sky is the limit. If the intent is to simply install Arch from the live media, run {{/arch/setup}}. If the intent is to edit an existing Linux install that got broken, follow the [[Install_from_Existing_Linux Install]] wiki article.
 
  
Want [[grub2]] or the ability to use [[GPT]] hardrives?
+
From here one is presented with the live environment's welcome message and is able to administer the target machine as if sitting at the physical keyboard. At this point, if the intent is to simply install Arch from the live media, follow the guide at [[Installation guide]]. If the intent is to edit an existing Linux install that got broken, follow the [[Install from existing Linux]] wiki article.
  
*Manually partition the target HDD/SDD using the '''gdisk''' utility installed via ''pacman -S gdisk'' before starting the arch installer and when presented with the option to install a boot loader in the installation framework, simply answer no and drop back to the live environment's root prompt.
+
{{Tip|Consider installing a [[List_of_applications#Terminal_multiplexers|terminal multiplexer]] on the target machine's live (in memory) system, so that if you are disconnected you can reattach to your multiplexer's session.}}
*Installation of grub2 is trivial at this point.  Simply chroot into the fresh arch install (default pre-mounted if coming out of the installer) then install and setup grub2:
 
 
 
cd /mnt
 
rm console ; mknod -m 600 console c 5 1
 
rm null ; mknod -m 666 null c 1 3
 
rm zero ; mknod -m 666 zero c 1 5
 
mount -t proc proc /mnt/proc
 
mount -t sysfs sys /mnt/sys
 
mount -o bind /dev /mnt/dev
 
chroot /mnt /bin/bash
 
 
 
Now inside the fresh Arch chroot:
 
 
 
pacman -S grub2
 
grep -v rootfs /proc/mounts > /etc/mtab
 
 
 
Edit {{Filename|/etc/defualt/grub}} to your liking.
 
Install grub and generate a grub.cfg
 
 
 
grub-install /dev/sdX --no-floppy
 
grub-mkconfig -o /boot/grub/grub.cfg
 
 
 
{{Note|The above assumes that if the user intends to boot from a GPT disk, the user has fully read and understood the aforementioned wiki articles and has made a 1M partition ef02 for grub2.}}
 
 
 
When ready to reboot into the new Arch install, exit the chroot and unmount the partitions prior to a reboot of the system.
 
 
 
exit
 
umount /mnt/boot  # if mounted this or any other separate partitions
 
umount /mnt/{proc,sys,dev}
 
umount /mnt
 
 
 
==Notes==
 
*If the target machine is behind a firewall/router, the default ssh port of 22 will obviously need to be forward to the target machine's LAN IP address.  The use of port forwarding is not covered in this guide.
 
*One can edit {{Filename|/etc/ssh/sshd_config}} on the live environment prior to starting the daemon for example to run on a non-standard port if desired.
 

Latest revision as of 08:25, 27 September 2018

Tango-go-next.pngThis article or section is a candidate for moving to Installation via SSH.Tango-go-next.png

Notes: Sounds better. (Discuss in Talk:Install from SSH#)

This article is intended to show users how to install Arch remotely via an SSH connection. Consider this approach over the standard one in scenarios such as the following:

  • Home theater PC without a proper monitor (e.g. an SDTV);
  • PC located in another city, state, country (friend's house, parent's house, etc.);
  • PC that you would rather setup remotely, for example from the comfort of one's own workstation with copy/paste abilities from the ArchWiki.

On the remote (target) machine

Note: These steps require physical access to the machine. Obviously, if physically located elsewhere, this will need to be coordinated with another person.

Boot the target machine into a live Arch environment via the Live CD/USB image: this will log the user in as root.

At this point, setup the network on the target machine as for example suggested in Installation guide#Connect to the Internet.

Secondly, setup a root password which is needed for an SSH connection, since the default Arch password for root is empty:

# passwd

Now check that PermitRootLogin yes is present (and uncommented) in /etc/ssh/sshd_config. This setting allows root login with password authentication on the SSH server.

Note: If the target machine is behind a NAT router, the SSH port (22 by default) will obviously need to be forwarded to the target machine's LAN IP address. The use of port forwarding is not covered in this guide.

Finally, start the openssh daemon with sshd.service, which is included by default on the live CD.

Note: After installation it is recommended to harden SSH. The first step would be to remove PermitRootLogin yes from /etc/ssh/sshd_config.

On the local machine

On the local machine, connect to the target machine via SSH with the following command:

$ ssh root@ip.address.of.target

From here one is presented with the live environment's welcome message and is able to administer the target machine as if sitting at the physical keyboard. At this point, if the intent is to simply install Arch from the live media, follow the guide at Installation guide. If the intent is to edit an existing Linux install that got broken, follow the Install from existing Linux wiki article.

Tip: Consider installing a terminal multiplexer on the target machine's live (in memory) system, so that if you are disconnected you can reattach to your multiplexer's session.