Into my second time writing about my experience doing some of the SysOps’ work. I found that I cannot use scp command to transfer a file from my Linux machine to the virtual machine.
scp (secure copy) is a command line utility that allows you securely copy files and directories between two locations, example from your local machine to a remote server or vice versa, or even two remote locations from your local machine.
scp [OPTION] [user@]SRC_HOST:]file1 [user@]DEST_HOST:]file2
- Option detail can refer to this link. Mainly, it is for ssh configuration, ssh port, recursive copy.
- SRC_HOST is the source file’s IP.
- DEST_HOST is the destination file’s IP.
You will use the scp command from your local machine. If you want to copy a file from your local machine to a remote server, the command can be something like,
scp file.txt remote_username@remote_server_ip:/remote/directory remote_username@remove_server_ip's password: file.txt 100% 0 0.0KB/s 00:00
It requires the user to enter password of the remote server before the transfer process starts. How about the other way round, copying a file from remote server to local machine? Do this at your local machine,
scp remote_username@remote_server_ip:/remote/file.txt /local/directory
It will prompt user to enter password too. So, what if want to transfer from two remote locations? Run this in your local machine,
scp email@example.com:/files/file.txt firstname.lastname@example.org:/files
There is an useful guide here.
I tried my luck but failed to connect. It showed timed out and cannot connect to port 22. Port 22 is a default listening port for SSH on the remote server. Then, I sought help from my IT guy again and after a few troubleshooting, we realized that the virtual machine network was NAT. It has to be changed to use “Bridged”.
Some instant notes of network access option,
The above shows me why I cannot run the scp command from my local machine. For NAT, it allows access from guest machine (virtual machine) to external network. In other words, from the virtual machine it allows to go to Internet but no communications between host machine (local machine) and guest machine. Changing the network to Bridged networking allows bi-directional communication.
Then, I tried again and it worked. It was a great experience to know about the network setting in a virtual machine. Besides that, my IT guy also told me that I can start the virtual machine with headless state, which using less memory, whenever I did not need the interface.