We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

Can I change the hostname on a SailfishOS Sony Xperia X?

asked 2017-12-27 18:57:03 +0200

JMLatJolla gravatar image

Basically, I like the standard hostname 'Sailfish' quite well, but a own name would be also very nice. :)

Well, in principle it is certainly possible to change the hostname, but the real question here is whether it is recommended or at least tolerated, without endangering the smooth running of the next update or negatively interfere on other kind of internal things... I've also noticed that the environment variable $HOSTNAME doesn't seem to be set.

Tx.

edit retag flag offensive close delete

Comments

stupid question, whats the sailfish hostname, whats mine?

DarkTuring ( 2017-12-28 03:14:23 +0200 )edit

also more accurately what is a hostname, whats its use in Linux?

DarkTuring ( 2017-12-28 03:15:11 +0200 )edit
1

Hi @DarkTuring, first of all, if you don't know something, there are no stupid questions. On the other hand, nowadays there are - thanks to the Internet - enough options for those eager to find out more about almost everything... :)

Now to your questions: The hostname is simply expressed let's say a human readable name of a network device that is directly linked to its IP address. This capability is not Linux-specific, but a cross-platform and even cross-protocol standard in network environments.

My SX X has hostname 'Sailfish' assigned and I suppose it will be the same for all SailfishOS devices around. When I do activate the WLAN connection, my phone is registered on my router/access point as 'Sailfish' with a specific IP address, let's say 123.4.5.6. If now a second SailfishOS device is active on the same network, then this second one will also get 'Sailfish' as his hostname (well, depending on the implementation, an extension is automatically appended to the second device with an identical name, e. g. Sailfish-1).

In order to be able to distinguish the single devices easily and unambiguously at any time, a dedicated host name per device can be assigned, e. g. 'MyPhone' and 'TheOtherPhone'. Another benefit is that you can contact the devices within local network by hostname and don't have first to find out which IP address it has.

Yo can find further information on the net, e. g. as a starting point at https://en.wikipedia.org/wiki/Hostname

JMLatJolla ( 2017-12-28 14:32:27 +0200 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2017-12-27 19:17:32 +0200

olf gravatar image

updated 2017-12-27 19:19:14 +0200

Patch: Custom hostname (under Patchmanager 2.0) does that nicely at the GUI.

Alternatively set the hostname by hand, as explained in Patch: Custom hostname's description.

I expected or experienced no negative effects within many months using it, but it allows to distinguish my SailfishOS phones in my WLAN easily.

edit flag offensive delete publish link more

Comments

Ok, thank you very much for the information, @olf. 'Patch: Custom hostname' seems to have been developed seriously and following standards - and also tested extensively... ;) Although I like to handle such kind of changing configuration stuff myself, I might use this package.

By the way, what is the recommended procedure for loading Openrepos content to your mobile?

JMLatJolla ( 2017-12-27 19:58:57 +0200 )edit

This should really be a configurable option without patches... However, it really doesn't affect everyday users, and there is a lot to fix before this, so sadly I think we will have use the patch route (or development mode terminal) for quite a while...

Direc ( 2017-12-27 20:28:14 +0200 )edit

While you don't use yet openrepos, it's probably doesn't concern you, but some software may use hostname. For example, system monitoring daemon collectd (used by SystemDataScope) has hostname as a part of its database path in default configuration. So, if you change hostname, I would recommend to stop collectd, move datasets, change hostname, and then start collectd again.

rinigus ( 2017-12-28 08:32:51 +0200 )edit
1

@rinigus: Yes, of course, the more services you have already installed, the more customizations need to be made, for example if you use LVM. That's why I made the hostname adjustment just at the beginning. But thanks for the advice.

JMLatJolla ( 2017-12-28 14:44:53 +0200 )edit
1

@JMLatJolla

By the way, what is the recommended procedure for loading Openrepos content to your mobile?

Warehouse (the classic OpenRepos.net client: well working, but its development has ceased) or Storeman (more features than Warehouse, does the job, but IMHO still in "release candidate / late beta" state).
Download either (or both) latest RPM, switch on "Untrusted software" in the SailfishOS settings, install Warehouse and / or Storeman RPM via File Manager (from the Jolla Store) or per pkcon install-local, and switch off the "Untrusted software" setting again: Done.

olf ( 2017-12-29 21:09:59 +0200 )edit
3

answered 2017-12-28 14:50:54 +0200

JMLatJolla gravatar image

As an information:

I did it by hand:

  • devel-su cp /etc/hostname /etc/hostname.$(hostname).$(date +%Y%m%d-%H%M%S).$USER

  • devel-su hostnamectl set-hostname "MyOwnNewName"

  • devel-su sed -i.$(hostname).$(date +%Y%m%d-%H%M%S).$USER -e "s:Sailfish:MyOwnNewName:g" /etc/ssh/ssh_host_ed25519_key.pub

  • devel-su sed -i.$(hostname).$(date +%Y%m%d-%H%M%S).$USER -e "s:Sailfish:MyOwnNewName:g" /etc/ssh/ssh_host_rsa_key.pub

edit flag offensive delete publish link more

Comments

So if I want to do this on my phone, I should replace MyOwnHostname everywhere in your answer by the hostname, I want to set? Correct? What about the " " ? It's a bit confusing for me. Sorry. I'd appreciate if you could clarify this. Thank you.

Loenneberga ( 2017-12-28 23:25:49 +0200 )edit
1

Hi @Loenneberga, yes MyOwnNewName is just a placeholder which you can replace with a name of your own choice. Please note that a hostname, if I remember correctly, may not exceed 64 characters and that exclusively Latin letters (aA to zZ), Arabic numbers (0 to 9) and as special character only the - (minus sign) are allowed, the last one not at the beginning of the hostname.

Each bullet corresponds to a single command line, even if it comes along as a two-liner through the forum layout, as for example the two devel-su sed... commands. The " belong to the commands and are required/necessary.

What will be done with those commands:

Bullet 1: Backup copy of file /etc/hostname is created -> /etc/hostname. Sailfish. 20171228-235946. nemo

Bullet 2: Hostname is changed.

Bullet 3: Within file /etc/ssh/ssh/ssh_host_ed25519_key. pub Sailfish string is replaced by the new name and at the same time a backup copy with the original value is generated.

Bullet 4: Dito Bullet 3, but with file /etc/ssh/ssh_host_rsa_key. pub

Before you start, enter the command hostname on the command line. The output of this command corresponds to the currently set hostname of your device. If it's not Sailfish, you have to use this displayed name instead of Sailfish in the change commands.

And one more important thing: I have re-configured my mobile phone and made these adjustments right after a fresh install, before I did major changes to the configuration and installed additional applications. As noted below by user @rinigus, additional components may be impacted by the hostname change and potentially require further adjustments.

One last recommendation: Always make a backup before fingerling around on the inner organs of your device...

JMLatJolla ( 2017-12-29 01:47:34 +0200 )edit

@JMLatJolla Thanks a lot. :)

Loenneberga ( 2017-12-29 03:20:50 +0200 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2017-12-27 18:57:03 +0200

Seen: 1,262 times

Last updated: Dec 28 '17