How to SSH with Pycharm a GCP VM without using the ephemeral external IP? - ssh

I have a GCE instance running on GCP. I can use my local Pycharm (Professional edition) to edit my code on the remote VM. The issue is that for the SSH connection (done inside Pycharm) it uses the external IP of the VM which is ephemeral. When stopping and restarting the VM I can get another external IP.
What is the best solution to not have to change the config of Pycharm everytime we have a new external IP ? (bastion ? static IP ? port forwarding ? hostname ?)
I need a solution that works without using gcloud cli directly (since it need to be setup inside Pycharm):
https://cloud.google.com/compute/docs/instances/connecting-advanced

The best option here is to reserve and assign the static IP to your VM.
Bastion Host will not work as you have to ssh into Bastion Host and then to your VM.

Related

Problem when change IP of Virtual Machine then using PuTTY to connect

I have an assignment to assign a new IP address to my VMware Ubuntu virtual machine and then deploy a WordPress site on it.
I used PuTTY to remotely connect from my Windows 10 host to the VM using ssh.
At first with the default config, I successfully deployed it.
However when I try to change the IP address of the VM by using UI I cannot connect through PuTTY anymore.
Is there anything I did wrong when I changed the IP address like that?
First, you can use openSSH instead of putty on Windows 10 nowoadays.
And you would then connect to it in command line with
ssh user#<serverName / IP address>
But, if you are using an IP address instead of a server name, then yes, changing said IP would change your URL (and your Putty configuration)

Forward server HTTP traffic to handle in another device via SSH Tunnel

I'm developing some webhook required direct access public domain to internal machine, thinking use SSH tunnel to forward data, or got alternative solution?
Hosting server & development machine are in same network
192.168.1.2/24 (Hosting server)
2nd machine is virtual mapping using forticlient firewall without static or dynamic IP in visible in hosting server, so is 1 way initial communication right now.
In this case possible to setup SSH tunnel forward all traffic from 192.168.1.2:80 to handle in development machine port 8080?
How to ssh syntax look like?
Thanks.
This could be done by setting up an SSH tunnel to the remote machine:
ssh -L localhost:80:localhost:8080 development-system
Every request to port 80 on the hosting-server is now forwarded to port 8080 on the development-system.
Please note, that the port 80 on the hosting-server could only be used, when you start the SSH command as root. Also note that the port 80 is only accessible from the hosting-server. To access the port 80 on the hosting-server from everywhere use the following:
ssh -L 80:localhost:8080 development-system
Be sure that you want that.
A good introduction to the topic could be found at
https://www.ssh.com/ssh/tunneling/example
https://unix.stackexchange.com/questions/115897/whats-ssh-port-forwarding-and-whats-the-difference-between-ssh-local-and-remot

What's the best way to reverse ssh tunnel to access system behind corp firewall?

I am trying to access a linux server through ssh. Typically this is accessed through a Win2012 jump server using putty.
I was able to setup a reverse ssh connection in putty from jump server to a AWS VM through HTTP proxy. And this was supposed to forward it to my linux server. But when I connect to my AWS VM and initiate ssh over my remote port, the whole thing just hangs. What am I doing wrong, and is there a better/easier way? No malicious intent, I have physical access to both jump server and linux server. Just bypassing shitty corp firewall.
Can you explain what you did in details ?
Typically on unix systems, for a reverse ssh tunnel, you can do this on your server behind the firewall:
ssh -NR ssh_port_AWS:localhost:ssh_port_local_server user#ip_AWS
You need to replace
ssh_port_AWS by the port of the distant server that you want to use to access the local server.
ssh_port_local_server by the port of the ssh server of your local server (if you don't change anything, 22).
user#ip_AWS by your AWS connection details (user#IP)

How to configure ubuntu host as private but virtual machine as public?

i trying to setup an apache proxy on VM. I have no issue that create the VM, i have setup the network for the connection between the host and VM through bridge connection. Now both host and VM can be access by the public.
But with client requirement, we are not allow to have the host as public. Hence i need go setup the host as internal network. Which means only the apache VM is allow to be ssh or ftp from outside, the host is not allow to be access from outside. All request will be proxy through apache VM.
Would like to know any export know how to do this ? Attached with the basic request diagram. Looking for the advice and answer. Thanks.
Info
Ubuntu 14.04 , Apache2 , KVM
The basic diagram
I really have stuck at this, what i have succesful setup is host and VM is accessible by public, via bridge connection.
When i try to set it as NAT conenection, the VM will be not accessible.
I have think an alternative way is block all the access port in the host, but host allowed to outbound , but not allowed inbound, but allow inbound from VM.
I hope have an expert help on this. Thanks.

Setting up a CNAME / Nickname for a remote server

Let's say I have a digital ocean droplet - 68.456.72.184
When ssh-ing into my remote server, I'd rather not have to type out the whole ssh command -
ssh 68.456.72.184
The host's name is Stormtrooper - how do I make it so that client machines can ssh into the server via
ssh Stormtrooper
I imagine this requires some sort of configuration on the local client machine that's connecting? In what order does does a client machine search for host names? I imagine there's some local setting where it looks for "Stormtrooper"'s IP address, and if not found it it looks in the local network, and then looks in the "global" network (i.e. public DNS).
I'm not quite sure how that lookup process works, so an explanation there would be great as well.
You can create local ssh_config in ~/.ssh/config with a content:
Host Stormtrooper
Hostname 68.456.72.184
And then you can ssh to that server using ssh Stormtrooper (even tab completion will work for you).
Connecting using FQDN will work too if you have correctly set up DNS. If you have a domain Stormtrooper.tld pointing to this IP, you are able to ssh using
ssh Stormtrooper.tld
For local network resolving, you would need local DNS, which would do this translation for you.