리눅스/우분투/라즈베리 잡학다식

[우분투] ssh 설치/설정 하기 ...

디폴트로 설치 되어 있어야 하는 거 아닌가. 라즈베리에서는 디폴트였던거 같은데

참고 : 우분투 메이트 16.04 LTS SSH 원격 제어를 위한 설정하기 | YeopBox, SSH(Secure SHell) 설치와 사용법(Ubuntu) – Programming Skills, 우분투 sshd 설치 - 제타위키

  • 라즈베리 파이..
pi@boriliketree:~ $ sudo dpkg --get-selections|grep ssh
libpam-chksshpwd:armhf				install
libssh-4:armhf					install
libssh-gcrypt-4:armhf				install
libssh2-1:armhf					install
openssh-client					install
openssh-server					install
openssh-sftp-server				install
ssh						install
pi@boriliketree:~ $ 

  • 우분투 버전 확인
bori@BorilikeGame:~$ netstat -ntlp | grep sshd
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
bori@BorilikeGame:~$ sudo service ssh status
[sudo] bori의 암호: Unit ssh.service could not be found.
bori@BorilikeGame:~$ dpkg --get-selections|grep ssh 
libssh-4:amd64					install
libssh-gcrypt-4:amd64				install
libssh2-1:amd64					install
openssh-client					install

  • 서버설치 및 테스트 : 아파트 NW는 공인 IP를 할당한다. ㄷ ㄷ ㄷ
bori@BorilikeGame:~$ sudo apt-get install openssh-server
bori@BorilikeGame:~$ sudo service ssh start

ssh 설정

  • 포트 번호 변경 : 22 -> 9949, 호스트/아이디패스워드 방식 X 비대칭키(공개키/비밀키)인증서방식 로그인
  • 비대칭키(RSA) 인증방식 : 비밀키(비공개키)은 본인이 가지고 있고 공개키를 누구에도 공개 암호화시 공개키로 암호화하여 공개키의 비밀키를 가진사람만이 비밀키로 복호화하여 인증하는 방식
  • 여기에서 서버는 BorilikeGame, 클라이언트는 boriliketree이므로 boriliketree에서 pi 사용자의 공개키/비밀키를 생성해서 서버에 pi의 공개키를 복사해주면 비대칭키 인증서방식으로 로그인 할 수 있음.
  • 포트 변경 검증
pi@boriliketree:~ $ ssh bori@175.207.67.147
ssh: connect to host 175.207.67.147 port 22: Connection refused
  • 호스트/아이디패스워드 방식 로그인 차단 검증
pi@boriliketree:~ $ ssh bori@175.207.67.147 -p9949
The authenticity of host '[175.207.67.147]:9949 ([175.207.67.147]:9949)' can't be established.
ECDSA key fingerprint is SHA256:Ae+9yGQx5G/tsUoMhmlrzzO465josCI70ETxeV9k9Aw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[175.207.67.147]:9949' (ECDSA) to the list of known hosts.
Permission denied (publickey).
pi@boriliketree:~ $ ssh bori@175.207.67.147 -p9949
Permission denied (publickey).
  • 공개키/비공개키 생성
pi@boriliketree:~ $ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/pi/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/pi/.ssh/id_rsa.
Your public key has been saved in /home/pi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:h1M8PCm8TUveFMqbI0iHtuF4hV5IU9lc5qloW1YLXXQ pi@boriliketree
The key's randomart image is:
+---[RSA 2048]----+
|      o..+ .+.o E|
|     . *.+o* + . |
|      B * & *    |
|     * B @ % .   |
|    . * S % o    |
|     . . B .     |
|        .        |
|                 |
|                 |
+----[SHA256]-----+
  • 로그인할 서버에 공개키 복사
pi@boriliketree:~ $ ssh-copy-id bori@175.207.67.147 -p9949
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/pi/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Permission denied (publickey).
  • 로그인할 서버(BorilikeGame)에 클라이언트(boriliketree)의 공개키를 복사하려고 했으나 서버 sshd 설정에서 아이디/패스워드설정을 차단해서 비대칭키 인증방식으로 로그 시도. 클라이언트 공개키가 아직 서버에 복사 되기 전이므로 실패함
  • 로그인할 서버(BorilikeGame) 에 클라이언트 공개키를 로그인 ID 홈디렉토리/.ssh/authorized_key파일에 등록해서 오류 해결
pi@boriliketree:~/.ssh $ ssh bori@175.207.67.147 -p9949
Welcome to Ubuntu 17.10 (GNU/Linux 4.13.0-46-generic x86_64결)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


패키지 0개를  업데이트할 수 있습니다.
0 업데이트는 보안 업데이트입니다.

Last login: Thu Sep  6 00:31:37 2018 from 175.207.61.169

[우분투] 버전/bit 확인

  • 버전확인
bori@BorilikeGame:~$ sudo cat /etc/issue
Ubuntu 17.10 \n \l

bori@BorilikeGame:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 17.10
Release:	17.10
Codename:	artful
bori@BorilikeGame:~$ uname -a
Linux BorilikeGame 4.13.0-46-generic #51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
bori@BorilikeGame:~$ sudo cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=17.10
DISTRIB_CODENAME=artful
DISTRIB_DESCRIPTION="Ubuntu 17.10"
NAME="Ubuntu"
VERSION="17.10 (Artful Aardvark)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 17.10"
VERSION_ID="17.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=artful
UBUNTU_CODENAME=artful
  • 비트 확인
bori@BorilikeGame:~$ dpkg -s libc6 | grep Arch
Architecture: amd64
Multi-Arch: same
bori@BorilikeGame:~$ uname -a
Linux BorilikeGame 4.13.0-46-generic #51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
bori@BorilikeGame:~$ uname -m
x86_64
bori@BorilikeGame:~$ 

[우분투]드디어 WOL

말만 들었던 해보고 싶었으나 웬지 못한 ... 그런데 이거 꼭 해야 하나

wol 설정

참고 : Choraengyi :: 우분투 스마트폰으로 원격 부팅

  • ethernet interface WOL 설정 + Bios set up
$ sudo apt-get install ethtool
$ sudo ethtool -s enp4s0 wol g
bori@BorilikeGame:/etc/systemd/system$ sudo systemctl enable wol@enp2s0
Created symlink /etc/systemd/system/multi-user.target.wants/wol@enp2s0.service → /etc/systemd/system/wol@.service.
bori@BorilikeGame:/etc/systemd/system$ systemctl is-enabled wol@enp2s0
enabled
  • 상기 설정으로 3번 on/off 테스트 성공 그러나 자고 일어나서 켜보려고 하니 안됨. 이유는??
  • 참고 : HOWTO: Set your system up for Wake On LAN (WOL)
  • 우분투 문제가 아니라 PC Bios 문제가 아닐까 하는 추정 --> 정전상태가 장시간(아마도 10분이상) 지속될 경우 WOL 작동하지 않은 거 같음

[우분투] 업그레이드 17.10 -> 18.04

$ sudo apt update 
$ sudo apt upgrade
$ sudo apt dist-upgrade
$ sudo apt install update-manager-core
$ sudo do-release-upgrade
  • 올바른 미러 사이트를 찾을 수 없음 에러 발생
  • source.list 변경 ftp.daum.net --> mirror.kako.com, artful --> bionic 으로 변경

[라즈베리파이 2] 무선 설정 하기

참고 : 라즈베리파이 무선랜 설정하기 > Raspberry Pi | HardCopyWorld

현상 : boriliketree 외장하드 마운트 오류 해결을 위해 커널업그레이드및 OS 업그레이드 거실 유선랜 연결 사용하다가 nextcloud 시범 설치 성능저하로 포기하고 서재방에서 사용하려고 무선 연결했는데 접속되지 않고 공유기 유무선단말정보에도 나타나지 않음

해결

  • 공유기 유무선단말 정보 0.0.0.0 으로 표시
  • 거실 유선랜 연결 (고정IP로 셋팅 해놓았음 172.30.1.29) 후 무선 네트워크 점검
pi@boriliketree:~ $ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::929f:33ff:fee9:d9ce  prefixlen 64  scopeid 0x20<link>
        ether 90:9f:33:e9:d9:ce  txqueuelen 1000  (Ethernet)
        RX packets 270  bytes 68087 (66.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 34  bytes 6817 (6.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 #무선랜 device 찾기
pi@boriliketree:~ $ lsusb
Bus 001 Device 006: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 001 Device 005: ID 046d:c534 Logitech, Inc. Unifying Receiver
Bus 001 Device 004: ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

pi@boriliketree:~ $ iwconfig
eth0      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11  ESSID:"NOTSPOT10"
          Mode:Managed  Frequency:2.412 GHz  Access Point: 00:07:89:39:49:41
          Bit Rate=65 Mb/s   Tx-Power=20 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=70/70  Signal level=-14 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:25   Missed beacon:0
          
  • 설정 파일 (/etc/wpa_supplicant/wpa_supplicant.conf) 수정
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

#iface eth0 inet manual
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 172.30.1.29
netmask 255.255.255.0
gateway 172.30.1.254

allow-hotplug wlan0
auto wlan0 #추가 eth0 고정IP 설정 시 효과 
iface wlan0 inet dhcp # manual -> dhcp로 변경
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  • network 서비스 재시작 후 wlan0  상태 점검 해결 !!!
pi@boriliketree:~ $ sudo service networking restart
pi@boriliketree:~ $ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.30.1.55  netmask 255.255.255.0  broadcast 172.30.1.255
        inet6 fe80::929f:33ff:fee9:d9ce  prefixlen 64  scopeid 0x20<link>
        ether 90:9f:33:e9:d9:ce  txqueuelen 1000  (Ethernet)
        RX packets 1295  bytes 323753 (316.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 148  bytes 32704 (31.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[우분투] 방어하기  feat 보안설정

참고 : UFW - Community Help Wiki, 우분투 UFW 방화벽 설정 방법 - 익스트림 매뉴얼

  • ufw enable 및 80,9949 오픈

UFW - Uncomplicated Firewall

The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptablesfirewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall. By default UFW is disabled.
bori@BorilikeGame:~$ sudo ufw status
상태: 비활성
bori@BorilikeGame:~$ sudo ufw enable
명령은 존재하는 ssh 연결에 피해를 줄 수 있습니다. 이 작업과 함께 진행하시겠습니까(y|n)? n
중지되었습니다
bori@BorilikeGame:~$ sudo ufw enable && sudo ufw allow 80 && sudo ufw allow 9949
명령은 존재하는 ssh 연결에 피해를 줄 수 있습니다. 이 작업과 함께 진행하시겠습니까(y|n)? y
방화벽이 활성 상태이며 시스템이 시작할 때 사용됩니다
규칙이 추가되었습니다
규칙이 추가되었습니다 (v6)
규칙이 추가되었습니다
규칙이 추가되었습니다 (v6)
bori@BorilikeGame:~$ sudo ufw status
상태: 활성

목적                         동작          출발
--                         --          --
80                         ALLOW       Anywhere
9949                       ALLOW       Anywhere
80 (v6)                    ALLOW       Anywhere (v6)
9949 (v6)                  ALLOW       Anywhere (v6)

비상모드 :  부팅이 안되는 상태에서 Root 콘솔 로그인 lock

참고 : Emergency Mode due to fstab - Raspberry Pi Forums

You could also add "init=/bin/sh" at the end of cmdline.txt, in the boot partition of the SD.
That would start you in a minimum shell environment, as root, where you should be able to "mount -o remount,rw /" (to mount the root partition in read-write mode), then "nano /etc/fstab" and comment out the offending line.
Then run "sync" once or twice, then "ex
it" (and there the OS will panic, this is OK)
After that, power off the Pi, remove "init=/bin/sh" from cmdline.txt, and reboot.
Hopefully the machine will start this time.
(systemd loves to put the system in emergency mode when a drive is missing --or simply just a bit too slow. Look for threads that mention options like nofail, x-systemd-automount, etc.)

위 내용대로 했는데 remout에서  에러가나서 아래와 같이 해서 해결. 근데 webdav를 마운트했다고 부팅이 되지 않는 걸까?  ...

참고 : Raspberry Pi Boot Issue - Root account locked!

In some cases you will not be able save your changes and the system will complain of a read only file system. If you get that move to the next sections
A raspberry pi SD card will has two main partitions, since we cannot read the partition table directly you must manually locate the device for your root and boot partitions. You can do this by going to the /dev directory and you should see something similar to mmcblk0p1 & mmcblk0p2. The second device mmcblk0p2 will be your root partition. You need to remount this with read write permissions
mount -o remount,rw /dev/mmcblk0p2 /
# mount -o remount,rw /partition/identifier /mount/point

[라즈베리파이3]부팅시 자동 시작 하기 : 서비스 관리

OS : Linux Borilikeharry 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux, Raspbian GNU/Linux 9 \n \l

부팅 시 자동 시작 방법 3가지(?) 정리하기 - /etc/rc.local, systemctl, service

service : init 스크립트,  systemd unit 또는 upstart job 실행

NAME
​       service - run a System V init script
SYNOPSIS
​       service SCRIPT COMMAND [OPTIONS]
   service --status-all
    
   service --help | -h | --version
DESCRIPTION
service  runs a System V init script, systemd unit, or upstart job in as predictable an environment as possible, removing most environment variables and with the current working directory set to /.
The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT, or the name of a systemd unit, or the name of  an upstart  job  in  /etc/init.  The existence of a systemd unit or upstart job of the same name as a script in /etc/init.d will cause the unit/job to take precedence over the init.d script.  The supported values of COMMAND depend on the invoked script.  service passes COMMAND  and  OPTIONS to the init script unmodified. For systemd units or upstart jobs, start, stop, status, and reload are passed through to their systemctl/initctl equivalents. For upstart jobs, restart will call the upstart 'stop' for the job, followed immediately by the 'start', and will exit with the return code of the start command.

All  scripts  should  support at least the start and stop commands.  As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. This option has no effect on upstart jobs.

service --status-all runs all init scripts, in alphabetical order, with the status command.  The status is [ + ] for running  services, [ - ] for stopped services and [ ? ] for services without a 'status' command.  This option only calls status for sysvinit jobs; upstart jobs can be queried in a similar manner with initctl list.

service 사용 예

  • service --status-all
pi@Borilikeharry:~ $ sudo service --status-all
 [ - ]  alsa-utils
 [ + ]  avahi-daemon
 [ + ]  bluetooth
 [ - ]  console-setup.sh
 [ + ]  cron
 [ + ]  dbus
 [ + ]  deluged
 [ + ]  dhcpcd
 [ + ]  dphys-swapfile
 [ + ]  fake-hwclock
 [ - ]  hwclock.sh
 [ - ]  keyboard-setup.sh
 [ + ]  kmod
 [ + ]  lightdm
 [ + ]  networking
 [ - ]  nfs-common
 [ + ]  nmbd
 [ - ]  paxctld
 [ + ]  plexmediaserver
 [ - ]  plymouth
 [ - ]  plymouth-log
 [ + ]  procps
 [ + ]  raspi-config
 [ - ]  rpcbind
 [ - ]  rsync
 [ + ]  rsyslog
 [ + ]  samba
 [ - ]  samba-ad-dc
 [ + ]  smbd
 [ + ]  ssh
 [ - ]  sudo
 [ + ]  triggerhappy
 [ + ]  udev
 [ - ]  x11-common

  • service  COMMAND status
pi@Borilikeharry:~ $ sudo service plexmediaserver status
● plexmediaserver.service - Plex Media Server for Linux
   Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-11-03 12:03:05 KST; 59min ago
  Process: 393 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLI
 Main PID: 421 (sh)
   CGroup: /system.slice/plexmediaserver.service
           ├─ 421 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Media Server"
           ├─ 427 /usr/lib/plexmediaserver/Plex Media Server
           ├─ 566 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Vers
           ├─ 994 /usr/lib/plexmediaserver/Plex DLNA Server
           ├─ 997 /usr/lib/plexmediaserver/Plex Tuner Service /usr/lib/plexmediaserver/Resources/Tuner/Private /usr/lib/plexmediaserver/Resources/
           └─2982 Plex Plug-in [com.plexapp.plugins.vimeo] /usr/lib/plexmediaserver/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resourc

11월 03 12:03:05 Borilikeharry systemd[1]: Starting Plex Media Server for Linux...
11월 03 12:03:05 Borilikeharry systemd[1]: Started Plex Media Server for Linux.
  • script 예 ) /etc/init/plexmediaserver.conf
# plexpms - service job file

description "Plex Media Server"
author "http://www.plexapp.com/"

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

# Sets nice and ionice level for job
nice -5

# What to execute
script
    if [ -r /etc/default/plexmediaserver ]; then
        . /etc/default/plexmediaserver
    fi
    start-stop-daemon --start -c $PLEX_MEDIA_SERVER_USER --exec /usr/sbin/start_pms
end script

systemctl : systemd 및 service manager  관리

SYSTEMCTL(1)                                                       systemctl                                                      SYSTEMCTL(1)
NAME
​       systemctl - Control the systemd system and service manager
SYNOPSIS
​       systemctl [OPTIONS...] COMMAND [NAME...]
DESCRIPTION
​       systemctl may be used to introspect and control the state of the "systemd" system and service manager. Please refer to systemd(1) for
​       an introduction into the basic concepts and functionality this tool manages.
  • systemd : 부팅시 최초 프로세스로 실행 되며, 사용자 서비스를 기동/관리
SYSTEMD(1)                                                          systemd                                                         SYSTEMD(1)
NAME
​       systemd, init - systemd system and service manager
SYNOPSIS
​       systemd [OPTIONS...]
   init [OPTIONS...] {COMMAND}
DESCRIPTION
systemd is a system and service manager for Linux operating systems. When run as first process on boot (as PID 1), it acts as init system that brings up and maintains userspace services.

systemctl 주요 명령어(COMMAND)

  • 기동/중지/상태/재기동 : start/stop/status/restart
  • reload : service configuration reaload
  • 서비스 등록/해제 : enable/disable
  • 사용 예 : 라즈베리파이 3에 매직미러 설치를 위해 불피요 서비스 중단('18.11.03)
pi@Borilikeharry:/etc/init $ sudo systemctl start plexmediaserver
pi@Borilikeharry:/etc/init $ sudo systemctl status plexmediaserver
● plexmediaserver.service - Plex Media Server for Linux
   Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-11-03 13:38:36 KST; 9s ago
  Process: 5876 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPL
 Main PID: 5880 (sh)
   CGroup: /system.slice/plexmediaserver.service
           ├─5880 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Media Server"
           ├─5884 /usr/lib/plexmediaserver/Plex Media Server
           └─5898 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-ecd600442/Framework.bundle/Contents/Resources/Vers

11월 03 13:38:35 Borilikeharry systemd[1]: Starting Plex Media Server for Linux...
11월 03 13:38:36 Borilikeharry systemd[1]: Started Plex Media Server for Linux.
pi@Borilikeharry:/etc/init $ sudo systemctl stop plexmediaserver
pi@Borilikeharry:/etc/init $ sudo systemctl status plexmediaserver
● plexmediaserver.service - Plex Media Server for Linux
   Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2018-11-03 13:38:59 KST; 5s ago
  Process: 5880 ExecStart=/bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Media Server" (code=killed, signal=TE
  Process: 5876 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPL
 Main PID: 5880 (code=killed, signal=TERM)

11월 03 13:38:35 Borilikeharry systemd[1]: Starting Plex Media Server for Linux...
11월 03 13:38:36 Borilikeharry systemd[1]: Started Plex Media Server for Linux.
11월 03 13:38:58 Borilikeharry systemd[1]: Stopping Plex Media Server for Linux...
11월 03 13:38:59 Borilikeharry systemd[1]: Stopped Plex Media Server for Linux.
pi@Borilikeharry:/etc/init $ sudo systemctl is-enabled plexmediaserver
enabled
pi@Borilikeharry:/etc/init $ sudo systemctl disable plexmediaserver
Synchronizing state of plexmediaserver.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable plexmediaserver
pi@Borilikeharry:/etc/init $ sudo systemctl is-enabled plexmediaserver
disabled
  • 예 ) [우분투] systemctl 로 서비스를 등록한 deluged/deluge-web umask  변경 후 재기 동
bori@BorilikeGame:/etc/systemd/system$ sudo systemctl restart deluged.service
Warning: The unit file, source configuration file or drop-ins of deluged.service changed on disk. Run 'systemctl daemon-reload' to reload units.
bori@BorilikeGame:/etc/systemd/system$ sudo systemctl daemon-reload deluged.service
Too many arguments.
bori@BorilikeGame:/etc/systemd/system$ sudo systemctl daemon-reload
bori@BorilikeGame:/etc/systemd/system$ sudo systemctl restart deluge-web

참고 : Ubuntu 16.04 system service 등록하기, SystemdForUpstartUsers - Ubuntu Wiki

리눅스 UMASK 설정

.fuse_hidden 파일?

참고 : fuse - what is a .fuse_hidden file and why do they exist? - Ask Ubuntu

You can safely ignore .fuse_hiddenXXXX files. It means a file was deleted but there is at least one software which is still using it, so it can't be removed permanently.
It will be done automatically when the relevant software stops using the file or exists. Such files are always gone after umount/reboot. This is how Linux and any Unix works but only FUSE exposes these files to the user.
  • 삭제 되었지만 삭제된 파일을 다른 프로세스가 사용중인 파일
  • 누가 사용하는지 알아보는 방법
Try lsof /just/the/directory/path instead, that lists everything that has a file open in that directory.
예)
bori@BorilikeGame:/media/usbhdd1/shares/plex-movie$ sudo lsof ./.fuse_hidden00000c2e00000003 
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
COMMAND   PID   USER   FD   TYPE DEVICE   SIZE/OFF  NODE NAME
deluged 13492 deluge   19r   REG   8,17 1898021092 26441 ./.fuse_hidden00000c2e00000003

ssh 오류

ssh publickey 개요

889ba9a9-924a-47f3-8adf-2c729fa47966
ssh 로그인 과정에 참여하는 파일은 크게 3가지로(known_hosts 파일 설명은 생략)아래의 3개 파일이 함께 저장되는 경우도 있으며 서버와 클라이언트에 따라 필요한 파일들만 존재 할 수도 있습니다. 그리고 키파일이 생성되지 않으면 아무런 파일이 없을 수도 있습니다.
authorized_keys
서버에서 인증된 공개키 정보(id_rsa)가 저장되는 파일 입니다. 여러개의 공캐기가 개행 문자로 나눠지면서 저장됩니다.
파일의 퍼미션은 반드시 600 (-rw——-)이 되어야 하며, 공개키에 해당되는 비밀키를 갖고 있는 클라이언트의 접속을 자동인증 처리합니다.
id_rsa.pub
로그인 인증에 사용되는 공개키 파일 내용으로, 로그인을 요청하는 클라이언트에는 없어도 되지만 공개키 내용이 서버의 authorized_keys 에 저장이 되어야 로그인이 가능합니다.
id_rsa
로그인에 사용되는 비밀키 파일로 외부에 노출이 되면 안됩니다. 그리고 비밀키 파일은 원격 서버에 접속하려는 클라이언트 PC에 존재해야 합니다. 인증에는 서버에 저장된 공캐키 내용과 클라이언트의 비밀키를 통해서 인증하게 됩니다. 따라서 하나의 키쌍으로 여러 고객사 정보 서버에 공개키를 저장해도 됩니다.
비밀키만 누출되지 않으면 여러 고객사에서 서로 같은 공개키가 저장되어도 같은 공개키가 저장된 서버끼리는 상호 접속이 불가능하기 때문에, 하나의 키쌍으로 여러 고객사 뿐만 아니라 내부 개발 서버에서 사용해도 됩니다.
출처 :  ssh 자동 로그인 인증 설정 - HiSEON

오류 내용

pi@Borilikeharry:~/.ssh $ ssh -v bori@igotoo.pw -p 9949
:
중략
:
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/pi/.ssh/id_dsa
debug3: no such identity: /home/pi/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/pi/.ssh/id_ecdsa
debug3: no such identity: /home/pi/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/pi/.ssh/id_ed25519
debug3: no such identity: /home/pi/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

해결

  • BorilikeGame의 authorized_keys  권한 644 > 600으로 변경. 권한이 600 아닐 보안상의 이류 해당 파일을 읽지 않음
bori@BorilikeGame:~/.ssh$ ls -al
합계 20
drwx------  2 bori bori 4096  9월 19 21:25 .
drwxr-xr-x 51 bori bori 4096  9월 19 21:52 ..
-rw-------  1 bori bori  795  9월  6 01:13 authorized_keys
-rw-------  1 bori bori 1679  9월  6 00:21 id_rsa
-rw-r--r--  1 bori bori  399  9월  6 00:21 id_rsa.pub

우분투 테마 변경하기

참고 : Adapta-gtk-theme - 가장 Material한 리눅스 테마 (Ubuntu 17.10 이상)

우분투 고정 IP 설정

참고 : Configure Static IP Addresses on Ubuntu 18.04 LTS Server | Website for Students, Ubuntu 18.04 / 고정 IP 설정하는 방법 – MANUAL FACTORY

Borilikegame DHCP 오류 : 자동으로 설정시(DHCP의 경우) 부팅후 timeout error로 네트워크 연결 오류

수동설정 (Static IP) 후 네트워크는 연결되었다고 나오나 인터넷이 되지 않고 외부에서도 접근이 안됨

  • DNS서버를 KT 서버로 설정후 정상작동하는 것으로 추정됨(2번 재부팅 시 한번은 오류 2번째는 정상)
1537795844007
  • KT 인터넷 구성?
  • 방마다 LAN 구성이 다르며 공인 IP 사용??
  • 서재방 : 175.207.67.0/25
  • 거실 : 175/207.61.0/25
  • 방간 네트워크 접근은 안됨 > 라우팅 하는 방법은 없을까?

Public IP 변경되다(10/15)

그동안 간헐적으로 IP를 못받아오고 한참걸리더니 KT에서 몬가 작업을 한거 같다.

오늘 퇴근후 접근을 하니 안되어서 DHCP에러가 발생했나보다 하고 와서 보니 유선네트워크 별일없이 연결되어 있다.

이런 서버 데몬들에게 문제가 생겼나 해서 모두 resatrt 했는데도 ... 여전히 불통

  • ifconfig 확인 결과 IP가 바뀌었다.   > 순간 공인 IP 어디서 구하히 KT에서 정책을 바꾸었나 보다.... 이런
bori@BorilikeGame:/media/usbhdd1/wordpress$ ifconfig enp2s0
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 221.153.50.93  netmask 255.255.255.128  broadcast 221.153.50.127
        inet6 fe80::230:67ff:fe4e:eab2  prefixlen 64  scopeid 0x20<link>
        ether 00:30:67:4e:ea:b2  txqueuelen 1000  (Ethernet)
        RX packets 170601  bytes 19140472 (19.1 MB)
        RX errors 0  dropped 132  overruns 0  frame 0
        TX packets 11023  bytes 1841245 (1.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 혹시나 해서 whatismyip 검색 결과 다행히 IP 만 바뀌었다.... 정말 다행
1539604727603
  • 구글 도메인 정보 변경
1539605098525

Public IP 변경되다2(12/14)

PC 소리가 커서 한동안 꺼놓고 있다 오랫만에 켜덨니 하드디스크 미인식으로 애를 먹이더니 IP까지 다시 변동되었다. 예전 IP인지는 확실하지 않다. 서버를 바꾸어야 할 때가 된 듯 NAS갈지 아니면 아예 Cloud를 이용할지 고민 해봐야 겠다.

  • ifconfig enp2s0 확인 결과
bori@BorilikeGame:/media/usbhdd1/wordpress$ ifconfig enp2s0
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 175.207.68.164  netmask 255.255.255.0  broadcast 175.207.68.255
        inet6 fe80::230:67ff:fe4e:eab2  prefixlen 64  scopeid 0x20<link>
        ether 00:30:67:4e:ea:b2  txqueuelen 1000  (Ethernet)
        RX packets 242920  bytes 252978628 (252.9 MB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 71001  bytes 6424002 (6.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 구글 도메인 정보 변경
1544926635492

외장하드 인식

enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
​        inet 175.207.68.164  netmask 255.255.255.0  broadcast 175.207.68.255

SSH between Mac OS X host and Virtual Box guest

작업일 : 2019년 3월 18일

출처 : SSH between Mac OS X host and Virtual Box guest · GitHub - 2014.08 자료

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

On Ubuntu (guest):

Install OpenSSH Server

Edit /etc/network/interfaces file to append the following lines:

auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0

Run sudo ifup eth1 from the Ubuntu command line. SSH server should be up and running. Switch to your host terminal and enter ssh 192.168.56.10

sources:

작업결과

VM 설정에서 host-only 어뎁터 추가 재부팅 후 ifconfig 확인 결과 enp0s8 생김

링크에서 말한대로 후속작업 즉 VM에서 인터페이스 추가 설정 작업 필요 없음

    igotoo@u4docker:~$ ifconfig
    enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
            inet6 fe80::74c7:fe3c:753:700f  prefixlen 64  scopeid 0x20<link>
            ether 08:00:27:d2:20:ab  txqueuelen 1000  (Ethernet)
            RX packets 706  bytes 523306 (523.3 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 527  bytes 216481 (216.4 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.99.100  netmask 255.255.255.0  broadcast 192.168.99.255
            inet6 fe80::f86d:1462:9633:7c66  prefixlen 64  scopeid 0x20<link>
            ether 08:00:27:e1:05:3a  txqueuelen 1000  (Ethernet)
            RX packets 169  bytes 16320 (16.3 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 221  bytes 18451 (18.4 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

default vm IP와 동일 충돌? DHCP이므로 default vm  다른 IP 할당할 것으로 예상됨 ... 아니다 default 설정파일에 IP 박혀 있음 …..

  • 이런 VM의 IP가 192.168.99.101로  변경됨
  • Docker Quickstart Terminal app 실행결과 : IP변경으로 ssh 오류 발생, 자체 수정 docker vm 기동
iMac:default igotoo$ bash --login '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'

Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.101:2376": x509: certificate is valid for 192.168.99.100, not 192.168.99.101
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/


docker is configured to use the default machine with IP 192.168.99.101
For help getting started, check out the docs at https://docs.docker.com
  • 정리 : VM 설정파일이 아닌 docker container 설정 파일 이었음 /Users/igotoo/.docker/machine/machines/default/config.json

ssh 확인

  • NAT 필요 없음 ... 외부 즉 맥 이외이 PC에서 접근 할려면 .....
iMac:machines igotoo$ ssh igotoo@192.168.99.100 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:w2bmtBG9kDM3zQsLEjFlEH6939M4AHXZz2S3jzMfSpU.
Please contact your system administrator.
Add correct host key in /Users/igotoo/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/igotoo/.ssh/known_hosts:21
ECDSA host key for 192.168.99.100 has changed and you have requested strict checking.
Host key verification failed.
iMac:machines igotoo$ cd .ssh
bash: cd: .ssh: No such file or directory
iMac:machines igotoo$ pwd
/Users/igotoo/.docker/machine/machines
iMac:machines igotoo$ cd ~
iMac:~ igotoo$ cd .ssh
iMac:.ssh igotoo$ ls -al
total 48
drwx------    7 igotoo  staff   238  9  5  2018 .
drwxr-xr-x+ 100 igotoo  staff  3400  3 18 00:48 ..
-rw-r--r--    1 igotoo  staff  5931  3 16 18:59 known_hosts
-rw-r--r--    1 igotoo  staff  1014  3  5  2015 known_hosts.openelec
-rw-r--r--    1 igotoo  staff   622 11 16  2010 known_hosts.org
-rw-r--r--    1 igotoo  staff  1410  3  2  2015 known_hosts.rasbian
-rw-r--r--    1 igotoo  staff   622  3  3  2015 known_hots
iMac:.ssh igotoo$ vi known_hosts
iMac:.ssh igotoo$ ssh igotoo@192.168.99.100 
The authenticity of host '192.168.99.100 (192.168.99.100)' can't be established.
ECDSA key fingerprint is SHA256:w2bmtBG9kDM3zQsLEjFlEH6939M4AHXZz2S3jzMfSpU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.99.100' (ECDSA) to the list of known hosts.
igotoo@192.168.99.100's password: 
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.18.0-16-generic x86_64)

정리(나의 생각...)

원인은?

이유가 뭔지 모르겠다. NAT 포워딩으로 설정을 해주었는데 안되고 다시 호스트 온리 NIC를 잡아 주어야 성공

VBox host IP 192.168.99.1 로 접속시 결과 : 차단됨

iMac:Scripts igotoo$ ssh -l igotoo 192.168.99.1 -p 1022
ssh: connect to host 192.168.99.1 port 1022: Connection refused
iMac:Scripts igotoo$ 

VM 10.0.2.15 접속 안됨 ... 맥에서 경로 없어 ping도 안됨

docker tool for Mac용 VM도 유사한 아니 거의 동일한설정을 했다....

버츄얼박스 자체가 하나의 Host 역할을 한다.

  • 도식 :  자기 PC ——> |VBox |——>VM ——> docker
  • VBox = Hypervisor
  • VM 호스트 전용 네트워크 NIC를 만들어서 맥과 VBox에서 접근할 수 있는 서브넷의 IP(192.168.99.100) 할당 받아 VM으로 접속할 수 있는 경로가 생겨서 해결 된 것으로 파악됨

남은 작업

  • 외부에서 VM 접근하기 ....
  • 외부에 알려진 IP는 맥의 IP ....그럼 맥에서 포워딩 해주는 작업이 필요 ....
  • 누가 포워딩 해주지 ... docker container Plex Media Sever 에서는 docker machine(vm) 포워딩 역할 수행(추정)
  • 포워딩 해주면 되지 않을까 ....
  • docker engine/docker-compose 설치
  • 공유폴던 권한 풀어주기 ....
  • default vm(docker vm)에서는 권한 문제는 없었는데.....
igotoo

igotoo