use SSH to connect to Raspberry Pi methods All In One
use SSH to connect to Raspberry Pi methods All In One
Raspberry Pi
user@hostname
# 无需知道 Raspberry Pi 的 IP Address, 即可使用 SSH 连接 👍
$ ssh pi@raspberrypi.local
user@hostip
# 需要使用 Wi-Fi Router / Nmap 等扫描工具获取 IP Address 👎
$ ssh pi@192.168.18.135

hostname
pi@raspberrypi:~ $ hostname -h
Usage: hostname [-b] {hostname|-F file} set host name (from file)
hostname [-a|-A|-d|-f|-i|-I|-s|-y] display formatted name
hostname display host name
{yp,nis,}domainname {nisdomain|-F file} set NIS domain name (from file)
{yp,nis,}domainname display NIS domain name
dnsdomainname display dns domain name
hostname -V|--version|-h|--help print info and exit
Program name:
{yp,nis,}domainname=hostname -y
dnsdomainname=hostname -d
Program options:
-a, --alias alias names
-A, --all-fqdns all long host names (FQDNs)
-b, --boot set default hostname if none available
-d, --domain DNS domain name
-f, --fqdn, --long long host name (FQDN)
-F, --file read host name or NIS domain name from given file
-i, --ip-address addresses for the host name
-I, --all-ip-addresses all addresses for the host
-s, --short short host name
-y, --yp, --nis NIS/YP domain name
Description:
This command can get or set the host name or the NIS domain name. You can
also get the DNS domain or the FQDN (fully qualified domain name).
Unless you are using bind or NIS for host lookups you can change the
FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
part of the FQDN) in the /etc/hosts file.
pi@raspberrypi:~ $ hostname -I
192.168.18.135 fd80:eae6:1258:0:d1c5:2a7f:abad:cbb5
pi@raspberrypi:~ $ hostname -i
127.0.1.1
pi@raspberrypi:~ $ hostname
raspberrypi
pi@raspberrypi:~ $ hostname -d
pi@raspberrypi:~ $ hostname -a
pi@raspberrypi:~ $

# macOS
➜ make git:(main) hostname
xgqfrms-mm.local
$ hostname -d
local
$ hostname -s
xgqfrms-mm
$ hostname -f
xgqfrms-mm.local
➜ make git:(main) man hostname
➜ make git:(main) hostname -h
hostname: illegal option -- h
usage: hostname [-f] [-s | -d] [name-of-host]

HOSTNAME(1) General Commands Manual HOSTNAME(1)
NAME
hostname – set or print name of current host system
SYNOPSIS
hostname [-f] [-s | -d] [name-of-host]
DESCRIPTION
The hostname utility prints the name of the current host.
The super-user can set the hostname by supplying an argument.
To keep the hostname between reboots, run ‘scutil --set HostName name-of-host’.
Options:
-f Include domain information in the printed name. This is the default behavior.
-s Trim off any domain information from the printed name.
-d Only print domain information.
EXAMPLES
Set the host name of the machine and check the result:
$ hostname beastie.localdomain.org
$ hostname
beastie.localdomain.org
Do not show domain information:
$ hostname -s
beastie
Show only domain information:
$ hostname -d
localdomain.org
SEE ALSO
gethostname(3), scutil(8)
HISTORY
The hostname command appeared in 4.2BSD.
macOS 13.1 October 5, 2020 macOS 13.1
demos
refs
©xgqfrms 2012-2021
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
未经授权禁止转载,违者必究!