Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I currently use SSHelper to transfer my data to the Android 4.0 device. The app displays the IP address that is currently assigned. Since this IP address changes regularly, I'd like to use a hostname for the device, with all my Linux computers, that works with Avahi/Zeroconf and I have computername.local.

How do I get such a hostname for my Android device?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

I am leaving my old answer since the browse and parsing examples may still be useful for some people.

Thanks to the developer's version 5.5 update to SSHelper, you can create a user defined name to be the phones Zeroconf instance name. SSHelper will run the SSH server on a non-rooted Android.

1. Update SSHelper to version 5.5
2. Open Android Bluetooth settings and turn on Bluetooth.
3. Now in lower right corner there is settings to "Rename phone". Customize the name.
4. Turn off Bluetooth if you want.
5. Restart SSHelper. 

It will register the Bluetooth name as the ZeroConf name. Now, as long as the machine you are connecting from has the avahi/bonjour client software, you can ping, ssh, sftp, or rsync to PhoneName.local. If you do not change your Bluetooth name, it will default register with the Device model name. e.g. "Nexus_4"

# For example:
ping Nexus_4.local
SSH Nexus_4.local
share|improve this answer

In the March 2014 update to SSHelper the documentation states new changes to it's Zeroconf broadcasting name. In the documentation Configuration section of the details it describes the checkbox to "Enable Zeroconf broadcasting". When this is enabled any other client on the local network, will be able to browse and then connect for SSHelper on the network.

Still though, SSHelper does not have the option to input a custom zeroconf name. The app automatically registers a Zeroconf instance name, which allows others to find any "SSHelper" on the network. As of SSHelper ver 5.0, the registered instance name is the model name of your android. For instance, "Nexus 4"

I agree this is not very helpful if there is more than one android "Nexus 4" running SSHelper, but if there is only one, then any remote client can connect to the android SSH server without having to know the it's name. You do not need to look at the SSHelper app to know which ip/hostname to connect to from your other machine.

From linux (you may need to install avahi-utils):

avahi-browse --terminate --resolve --parsable _ssh._tcp

More specifically, entering this command will SSH connect to the android e.g. "Nexus 4" server without needing to know it's name:

ssh `avahi-browse --terminate --resolve --parsable _ssh._tcp \
| grep "Nexus.*;local;" \
| sed -E 's/.*Nexus.*;local;(.*.local);.*/\1/g'`

For OS X (10.9 Mavericks), there is nothing to install but you must run dns-sdand then Ctrl + C to kill the process after you see the android bonjour hostname.

# If your model name is not "Nexus 4", Be sure to use your phones model name.
dns-sd -L "Nexus 4" _ssh._tcp local

# this will output something like this:
# Nexus\0324._ssh._tcp.local. can be reached at 192-168-1-6.local.:22

# so now ping by the name found from above:
ping 192-168-1-6.local
share|improve this answer
    
Thanks for the code snippet, that works great! –  queueoverflow Dec 13 '13 at 19:23
    
Yes, it's really a pity that--accordig to your description--it's not possible to set a human-friednly hostname, just to do ssh MY-ANDROID.local!.. –  imz -- Ivan Zakharyaschev Jan 3 at 22:56

I have yet to find a way to create a hostname for an Android device. What I have done is that I set an IP reservation for my phone, so that every time I go to use SSH (I use QuickSSHd, but it should work for SSHelper) you can at least point to the same IP address.

There is no way to set a host name for the phone, that I have found.

share|improve this answer
1  
Okay I lied, there is an easy way to change the hostname, but it's not what you'd expect for trying to SSH. You can use getprop hostname.net and setprop hostname.net NEW_NAME to change the hostname of your phone and how it appears to you router, but this does not let you SSH by hostname. –  Mr. Monkey Mar 26 '13 at 17:15
    
Actually it's net.hostname, but without your comment I wouldn't have found it. –  elmicha Nov 1 '13 at 23:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.