2014年11月18日 星期二

CentOS 7設定SSH連線

CentOS 7設定SSH連線

CentOS 7終於安裝好也設定固定IP了,
接下來就是設定SSH連線,這樣在遠端也可以連線操作,
且使用PieTTY這類軟體要截圖的話就方便多了。

1. 修改/etc/ssh/sshd_config
Port 4444
PermitRootLogin no


2. 使用非預設port要將port加入selinux,使用semanage指令,
semanage在最小安裝預設是沒有的,所以必須先安裝"policycoreutils-python",
安裝好後以root執行
$ semanage port -a -t ssh_port_t -p tcp 4444

$ semanage port -l       <----查詢


3. 修改防火牆(firewalld)
$ firewall-cmd --permanent --zone=public --add-port=4444/tcp
$ firewall-cmd --reload


4. restart ssh service
$ service sshd restart
or
$ systemctl restart sshd.service


可用netstat查看(要安裝net-tools)
$ netstat -tunlp






2014年11月15日 星期六

CentOS 7 DHCP改固定IP

CentOS 7 DHCP改固定IP

修改/etc/sysconfig/network-scripts/ifcfg-(connection)

BOOTPROTO=static
IPADDR=192.168.xxx.xxx
NETMASK=255.255.255.0
GATEWAY=192.168.xxx.xxx

Restart network service.
$ service NetworkManager restart

改為固定IP後卻發生yum error was 14: curl#6 - "Could not resolve host"

Solution:

修改/etc/sysconfig/network-scripts/ifcfg-(connection)

DNS1=168.95.1.1

or

修改/etc/resolv.conf

nameserver 168.95.1.1

搞定!!

2014年11月13日 星期四

CentOS 7最小安裝後網路設定

CentOS 7最小安裝後網路設定

CentOS 7預設為NetworkManager,要使用nmcli指令。


Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OPTIONS
  -t[erse]                                   terse output
  -p[retty]                                  pretty output
  -m[ode] tabular|multiline                  output mode
  -f[ields] <field1,field2,...>|all|common   specify fields to output
  -e[scape] yes|no                           escape columns separators in values
  -n[ocheck]                                 don't check nmcli and NetworkManager versions
  -a[sk]                                     ask for missing parameters
  -w[ait] <seconds>                          set timeout waiting for finishing operations
  -v[ersion]                                 show program version
  -h[elp]                                    print this help

OBJECT
  g[eneral]       NetworkManager's general status and operations
  n[etworking]    overall networking control
  r[adio]         NetworkManager radio switches
  c[onnection]    NetworkManager's connections
  d[evice]        devices managed by NetworkManager

連線wifi

$ nmcli d wifi connect <SSID> password <password>

查詢IP

$ ip a


Centos 7 USB安裝失敗

Centos 7 USB安裝失敗


問題描述:

ISO檔以rufus建立可開機USB,
安裝時出現"Warning: /dev/root does not exist, could not boot"錯誤訊息,

解決方法:

安裝時選Install CentOS 7並按TAB鍵,
將參數修改為"vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb1:/ quiet"