download a file from a linux google cloud server into my pc - google-cloud-platform

I have some pdf's into linux server and I want to download them into my pc. I am trying to use somthing like this
scp username#instance_name:/path_to_this_file/XXX.pdf C:\Users\username\Desctop
but isn't working, do you have any idea how to deal with that?

It would be helpful if you include in your question the errors you're receiving.
scp is a *nix command (not Windows) and so you likely can't use that command on Windows.
See: Transferring files to (from) Linux VMs
If you have a Linux shell (e.g. WSL) then the easiest way is probably to use gcloud compute scp which provides a wrapper around scp for you.

Related

deploying to ubuntu instance on aws from windows

I want to deploy a python project to ubuntu instance on aws from a windows operating system, but all tutorials I have encountered either use ubuntu or mac as their development/local machine.
Is the deployment from windows the same i.e. after createing the instance all I would then be doing from the local windows system would be running inside the ubuntu instance?
is there any tutorial which can help me achieve my objective?
Note i am deploying directly without git.
ANy help would be appreciated
To transfer files to an ubuntu instance you could use SSH, from windows you could download an SSH client such as Mobaxterm (https://mobaxterm.mobatek.net/)! or download Windows Subsystem for Linux (https://learn.microsoft.com/en-us/windows/wsl/install-win10)! then use SCP to copy files (https://www.computerhope.com/unix/scp.htm)!. Both options require that you have the .pem security file for your instance
Your best bet is going to be installing WSL(Windows Subsystem for Linux) and using that to run bash commands. This will make your life a whole lot easier as you won't have to look for Windows specific tutorials and you can now follow Ubuntu/Linux tutorials.
What is WSL? It is essentially a Linux VM built into Windows. It will provide you with a terminal running Ubuntu or pretty much any other Linux distro you could want.
How to install WSL

Is it possible to download file or folders from AWS Linux EC2 instance to local Windows 10 machine?

I am having one Linux Ec2 instance on AWS and my local machine is Windows 10 (64-bit).
I want to download some files or folders from Ec2 to location windows machine.
I am not sure whether it is possible or not? if yes, how we can do that.
thanks.
I tried this it worked for me.
Download https://mobaxterm.mobatek.net/ its an Enhanced terminal for Windows.
You can link your EC2 instance directly via SSH its pretty simple to set up. Just follow the instuctions they've given. Once linked, its super easy to export, import, create files and folders all via mobaxterm.
folders in mobaxterm:
Got the command to Copy from Windows to Linux.
First you need to install putty (putty-64bit-0.74-installer.msi) on your windows machine
The Command is as follow it will copy the folder(e.g. DokerAutomationResult) to the windows machine from AWSLinux machine.
pscp -r ubuntu#xx.xxx.xx.xx:/home/ubuntu/DokerAutomationResult ./
[pscp -r ubuntu#(ipAddress):(locationOfLinuxFileLocation /(locationToCopyInWInodws) ]
For better Understanding:
https://www.youtube.com/watch?v=Sc0f-sxDJy0&ab_channel=Liv4IT
Yes it is possible to download files from ec2 linux instance to local system.
You can use scp -i key user#ip add:/file location which you want to download.
. will download file in your current location on local system

Run .sh script using Google Cloud SDK shell

I'm trying to automate deploying code to my 3 GCE Linux VM's. I read this article Scripting with gcloud: a beginner’s guide to automating GCP tasks, it shows how to make a script. Now I assume that means saving the code as a .sh file (it even has a shebang on top), now how do I run that. Do I type the script file name in the Google Cloud SDK Shell? I tried it, it does not seem to work. can someone help me? I will really appreciate.
Here is an image of my google cloud shell where I am trying to use the script files.
You're able to install Google Cloud SDK on variety of operation systems such as Linux, macOS and Windows. After that, you'll be able to use same commands like gcloud, gsutil and bq. Meanwhile, scripting relies on the command-line interpreters: you can use bash with Linux and macOS, but for Windows you should use cmd and PowerShell. You can run examples provided at the article, you've mentioned, and at the documentation Scripting gcloud CLI commands with bash on Linux and macOS, so the error messages you've got were expected. You can't run .sh scripts on windows naively, as it was mentioned by #Pievis at the comment section.
As a possible workaround you can install Windows Subsystem for Linux (WSL) for Windows 10 (usually you can choose between WSL2 and WSL1, but it depends on build version of your Windows 10) to get some interoperability between Windows and Linux.
If you need to transfer files to you VM instances please follow the documentation Transferring files to VMs.
If you are interested in automation with GCP, please have a look on the documentation Infrastructure as code to "automate repeatable tasks like provisioning, configuration, and deployments".

Is there a way to open and modify a python file in a virtual machine of google cloud platform?

I just started to use cloud to do training for my deep learning program. For now every time I modified my local .py file I have to remove the old one in the remote virtual machine of Google Cloud Platform and upload the new one. I am just curious if there is a way that I can actually open the .py file in the remote visual machine through the command line? That would be very high efficiency.
Thank you very much!
To edit a file on a machine you can SSH into there are many potential solutions.
Use scp to copy files. E.g. scp mylocalfile ssh://my-host-address/myfolder
Use ssh mounting solutions: How do you edit files over SSH?
Edit using nano your-file-to-edit (my favorite) https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/
Edit using vi or vim http://vim.wikia.com/wiki/Tutorial

Compile SSH into C++ app

I need to use SSH to remotely send commands to other servers from a Windows box. Is there source out there I can use to build SSH into an app so I don't have to use cygwin or anything like that?
Thanks!
There is a libssh you can use; you could also embed the PuTTY source code (I believe winscp does this).