Host transfers files to KVM virtual machine via FTP

Machine environment: Host: ubuntu16.04 KVM version: QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.16) Virt...

Machine environment:
Host: ubuntu16.04
KVM version: QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.16)
Virtual Machine: Ubuntu-Server 16.04.3 LTS

Install FTP, File Transfer in ubuntu Server

  • The network is connected.Install openssh server

    $sudo apt-get install openssh-server $sudo apt-get install openssh-sftp-server
  • Install ftp service - vsftpd server

    $sudo apt-get install vsftpd
  • Connect locally to the server in the virtual machine

    $ ssh username@IP username@IP's password: Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 94 packages can be updated. 47 updates are security updates. Last login: Tue Dec 12 09:07:41 2017 from IP eric@oracle-server:~$
  • Start ftp

    eric@oracle-server:~$ service vsftpd start ##Restart service vsftpd restart ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to start 'vsftpd.service'. Authenticating as: eric,,, (eric) Password: ==== AUTHENTICATION COMPLETE === ##View Status eric@oracle-server:~$ service vsftpd status ● vsftpd.service - vsftpd FTP server Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: e Active: active (running) since Tue 2017-12-12 09:46:49 CST; 28s ago Process: 2285 ExecStartPre=/bin/mkdir -p /var/run/vsftpd/empty (code=exited, s Main PID: 2288 (vsftpd) Tasks: 1 Memory: 396.0K CPU: 4ms CGroup: /system.slice/vsftpd.service └─2288 /usr/sbin/vsftpd /etc/vsftpd.conf Dec 12 09:46:49 oracle-server systemd[1]: Stopped vsftpd FTP server. Dec 12 09:46:49 oracle-server systemd[1]: Starting vsftpd FTP server... Dec 12 09:46:49 oracle-server systemd[1]: Started vsftpd FTP server.#Start Successful

  • Modify Profile

    In/etc/Vsftpd.confMedium Ensure

    write_enable = YES,

    anonymous_enable=YES,anon_upload_enable=YES,

    anon_mkdir_write_enable=YES

    Save and restart the server.

  • Create send and receive folders in the host and virtual machines, and grant privileges

    #Host $mkdir share $chmod 777 share #virtual machine $mkdir tmp $chmod 777 tmp
  • File upload to virtual machine

    ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. drwxrwxr-x 2 1000 1000 4096 Dec 12 09:52 tmp 226 Directory send OK. ftp> cd tmp 250 Directory successfully changed. ftp> put /home/eric/share/kvm.md ./kvm.md#Error may occur if the file name is not specified local: /home/eric/share/kvm.md remote: ./kvm.md 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 Transfer complete. 601 bytes sent in 0.00 secs (14.3290 MB/s) ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. -rw------- 1 1000 1000 601 Dec 12 10:28 kvm.md -rw------- 1 1000 1000 3453696911 Dec 12 09:54 oracle12cr2.zip
  • Probable problems

    Error uploading file:

    permission denied

    1. Consider whether it's selinux or not. Try disabling selinux
    2. Maybe the folder of ftp does not have write permission, confirm the permission of the directory
    3. Change the permissions in the configuration file to YES (refer to the configuration file above)

    Could not create file

    Specify file name: put/home/user/share/Kvm.mdHome/eric/tmp/Kvm.md

7 June 2020, 12:48 | Views: 2322

Add new comment

For adding a comment, please log in
or create account

0 comments