欢迎来到战五渣的博客

人生三重境界:昨夜西风凋碧树,独上高楼,望尽天涯路。 衣带渐宽终不悔,为伊消得人憔悴。 众里寻他千百度,蓦然回首,那人却在灯火阑珊处。

vmware安装ubuntu的简单配置

介绍:ubuntu是一个桌面体验比较好的linux操作系统,尝试使用vmware安装一个虚拟机试用一下,做个简单记录,安装操作系统步骤省略

一、配置root用户,并使用root登录图像界面

Ubuntu18.04默认不允许以root用户进行登录,通过以下配置可以登录root用户

1.1  创建root用户的密码

joy@joy-virtual-machine:/root$ sudo passwd root

[sudo] password for joy:    #输入joy密码
Enter new UNIX password:    #设置root密码  
Retype new UNIX password:   #确认
passwd: password updated successfully

1.2 修改50-unity-greeter.conf文件

增加两行:

joy@joy-virtual-machine:~$ sudo vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

greeter-show-manual-login=true
all-guest=false

1.3 进入/etc/pam.d目录,修改gdm-autologin和gdm-password文件

joy@joy-virtual-machine:~$ vi /etc/pam.d/gdm-autologin 

注释掉auth required pam_succeed_if.so user != root quiet_success这一行

#auth   required        pam_succeed_if.so user != root quiet_success

joy@joy-virtual-machine:~$ vi /etc/pam.d/gdm-password 

注释掉 auth required pam_succeed_if.so user != root quiet_success这一行

#auth   required        pam_succeed_if.so user != root quiet_success

1.4 修改/root/.profile文件

joy@joy-virtual-machine:~$ sudo vi /root/.profile

将文件末尾的mesg n || true这一行修改成tty -s&&mesg n || true

tty -s&&mesg n || true

1.5 重启系统

输入root用户名和密码,登录系统

二、安装vmware tools

2.1 在vmware的虚拟机选项,点击安装VMware Tools

则在桌面会出现一个VMware Tools的DVD图标,如下图:

2.2 挂载cdrom,并进行解压安装

root@joy-virtual-machine:~# mount /dev/cdrom /root/Desktop/vmware/

mount: /root/Desktop/vmware: WARNING: device write-protected, mounted read-only.

root@joy-virtual-machine:~# cd /root/Desktop/vmware/

-r-xr-xr-x 1 root root     1975 9月   4  2018 manifest.txt*
-r-xr-xr-x 1 root root     4413 9月   4  2018 run_upgrader.sh*
-r--r--r-- 1 root root 55491492 9月   4  2018 VMwareTools-10.3.2-9925305.tar.gz
-r-xr-xr-x 1 root root   847468 9月   4  2018 vmware-tools-upgrader-32*
-r-xr-xr-x 1 root root   893640 9月   4  2018 vmware-tools-upgrader-64*

root@joy-virtual-machine:~/Desktop/vmware# tar -xf VMwareTools-10.3.2-9925305.tar.gz -C /opt/

root@joy-virtual-machine:~/Desktop/vmware# cd /opt/

root@joy-virtual-machine:/opt# cd vmware-tools-distrib/

root@joy-virtual-machine:/opt/vmware-tools-distrib# ll

drwxr-xr-x  2 root root   4096 9月   4  2018 bin/
drwxr-xr-x  5 root root   4096 9月   4  2018 caf/
drwxr-xr-x  2 root root   4096 9月   4  2018 doc/
drwxr-xr-x  5 root root   4096 9月   4  2018 etc/
-rw-r--r--  1 root root 142493 9月   4  2018 FILES
-rw-r--r--  1 root root   2538 9月   4  2018 INSTALL
drwxr-xr-x  2 root root   4096 9月   4  2018 installer/
drwxr-xr-x 14 root root   4096 9月   4  2018 lib/
drwxr-xr-x  3 root root   4096 9月   4  2018 vgauth/
-rwxr-xr-x  1 root root 223540 9月   4  2018 vmware-install.pl*

 2.3 开始安装

root@joy-virtual-machine:/opt/vmware-tools-distrib# ./vmware-install.pl

open-vm-tools packages are available from the OS vendor and VMware recommends 
using open-vm-tools packages. See http://kb.vmware.com/kb/2073803 for more 
information.
Do you still want to proceed with this installation? [no] yes
INPUT: [yes]
Creating a new VMware Tools installer database using the tar4 format.
Installing VMware Tools.
In which directory do you want to install the binary files? 
[/usr/bin] 
INPUT: [/usr/bin]  default
What is the directory that contains the init directories (rc0.d/ to rc6.d/)? 
[/etc] 
INPUT: [/etc]  default
What is the directory that contains the init scripts? 
[/etc/init.d] 
INPUT: [/etc/init.d]  default
In which directory do you want to install the daemon files? 
[/usr/sbin] 
略过…… To enable advanced X features (e.g., guest resolution fit, drag and drop, and file and text copy/paste), you will need to do one (or more) of the following: 1. Manually start /usr/bin/vmware-user 2. Log out and log back into your desktop session 3. Restart your X session. Enjoy, --the VMware team Found VMware Tools CDROM mounted at /media/root/VMware Tools. Ejecting device /dev/sr0 ... Found VMware Tools CDROM mounted at /root/Desktop/vmware. Ejecting device /dev/sr0 ...

安装完成!!!

三、远程使用root登录Ubuntu

root@joy-virtual-machine:~# ps -e | grep ssh

1501 ?        00:00:00 ssh-agent

root@joy-virtual-machine:~# apt-get install openssh-server

root@joy-virtual-machine:~# vi /etc/ssh/sshd_config

PermitRootLogin yes

root@joy-virtual-machine:~# service sshd restart

测试成功!!!

四、安装openvpn客户端

4.1 初步安装openvpn

root@joy-virtual-machine:~# apt-get install openvpn

把配置文件移到固定的路径:

root@joy-virtual-machine:/etc/openvpn/client# cp /root/Desktop/config/*  /etc/openvpn/client/

root@joy-virtual-machine:/etc/openvpn/client# ll

-rwxr--r-- 1 root root 1818 3月  13 17:43 ca.crt*
-rwxr--r-- 1 root root  666 3月  13 17:43 open.ovpn*
-rwxr--r-- 1 root root  340 3月  13 17:43 README.txt*
-rwxr--r-- 1 root root  636 3月  13 17:43 ta.key*

修改open.ovpn

root@joy-virtual-machine:/etc/openvpn/client# vi open.ovpn

client
dev tun
proto tcp 
remote *.*.*.* 1194
auth-user-pass
resolv-retry infinite
remote-cert-tls server
nobind
persist-key
persist-tun
comp-lzo
verb 3
ca ca.crt

root@joy-virtual-machine:/etc/openvpn/client# openvpn /etc/openvpn/client/open.ovpn 

Wed Mar 13 17:48:38 2019 OpenVPN 2.4.4 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Sep  5 2018
Wed Mar 13 17:48:38 2019 library versions: OpenSSL 1.1.0g  2 Nov 2017, LZO 2.08
Enter Auth Username: joy
Enter Auth Password: ***********

查看:

root@joy-virtual-machine:/etc/openvpn/client# ip addr

tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
    link/none 
    inet 10.8.0.253 peer 10.8.0.254/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::c0eb:3b43:ccfa:d11/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever

4.2 配置文件调用用户名和密码

把用户名和密码写进一个文件,使用配置文件调用,可以免输用户名和密码,操作如下:

root@joy-virtual-machine:/etc/openvpn/client# pwd

/etc/openvpn/client

定义用户名密码文件

root@joy-virtual-machine:/etc/openvpn/client# vi account.txt

ubuntu
password

修改open.ovpn

client
dev tun
proto tcp 
remote *.*.*.* 1194
auth-user-pass /etc/openvpn/client/account.txt  #定义用户名和密码文件位置
resolv-retry infinite
remote-cert-tls server
nobind
persist-key
persist-tun
comp-lzo
verb 3
ca ca.crt

测试连接

root@joy-virtual-machine:/etc/openvpn/client# openvpn /etc/openvpn/client/open.ovpn 

root@joy-virtual-machine:/etc/openvpn/client# ip addr

tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
link/none
inet 10.8.0.249 peer 10.8.0.254/32 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::6ecf:d442:9dc0:d53a/64 scope link stable-privacy
valid_lft forever preferred_lft forever

4.3 做一个别名

直接输入openvpn就可以在后台连接

root@joy-virtual-machine:/etc/openvpn/client# vi /root/.bashrc 

alias openvpn='openvpn /etc/openvpn/client/open.ovpn &' 

root@joy-virtual-machine:/etc/openvpn/client# source /root/.bashrc

root@joy-virtual-machine:/etc/openvpn/client# openvpn

执行成功,但有一个问题,必须在当前目录执行,否则报错

root@joy-virtual-machine:/etc/openvpn/client# cd

root@joy-virtual-machine:~# openvpn

[1] 5160
root@joy-virtual-machine:~# Options error: --ca fails with 'ca.crt': No such file or directory (errno=2)
Wed Mar 13 18:21:12 2019 WARNING: file '/etc/openvpn/client/account.txt' is group or others accessible
Options error: Please correct these errors.
Use --help for more information.

[1]+  Exit 1                  openvpn /etc/openvpn/client/open.ovpn

所以,别名这样写

root@joy-virtual-machine:~# vi /root/.bashrc

alias openvpn='cd /etc/openvpn/client;openvpn /etc/openvpn/client/open.ovpn &'

root@joy-virtual-machine:~# source /root/.bashrc

root@joy-virtual-machine:~# openvpn

root@joy-virtual-machine:~# ip addr

tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 100
    link/none 
    inet 10.8.0.249 peer 10.8.0.254/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::60b4:bad8:79ab:a618/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever

成功配置openvpn客户端

 

posted @ 2019-03-13 17:15  梦中泪  阅读(938)  评论(0编辑  收藏  举报