How do I set up SSH firewall rules on a Google VM so that only my office computer can access the VM via SSH?


Vishwakarma

My Google VM has been under constant threat the last few days and I'm getting a warning and facing Google suspending the VM saying "Cryptocurrency mining activity detected on the VM". I suspect that someone hacked into my VM and did this activity. So now I want to create a new VM with a secure SSH firewall so that only limited machines can access the VM.

I have tried setting the IP of my office router on the firewall ssh allow rule, but after setting this rule, the SSH connection to the VM does establish from a different IP address as well. I just want to specify two IPs in the firewall rule, but it requires IP ranges in CIDR format (I don't know exactly).

I also found some suggestions that I should change the ssh port of the VM.

Can anyone explain how I can restrict access to my Google VM to only a specific set of computers when this computer is connected to the router and all routers have the same external IP?

thanks

Mohammad Ebaduddin

I understand that you want to create a new virtual machine with a secure firewall SSH and want to restrict and allow access from a specific IP address of your office router.

To do this, you can create firewall rules as described in 1 here . To manage access to a specific instance, I recommend that you use network labels for firewall rule 2 .

Going back to your concern, even if you create a firewall rule for a specific IP address, SSH connections to the VM will indeed be established from other IP addresses. The reasons for this may be:

Every project you create in GCP comes with default firewall rules. So you might need to block a default-allow-ssh rule, which I think might be causing the problem. Note that the default network includes some additional rules that override this, allowing certain types of incoming traffic. See Additional Links [3][4] for more details.

[3] https://cloud.google.com/vpc/docs/firewalls#default_firewall_rules [4] https://cloud.google.com/vpc/docs/firewalls#more_rules_default_vpc

You can also use eg "iptables" to add guest level firewall rules to add another level of security to your VM instance. However, GCP project-level firewall rules are responsible for inspecting network traffic before it enters your VM instance. The OS firewall blocks all internet traffic to any port 22.

To allow specific addresses to be able to connect to your VM instance, you can add a CIDR of /32 to the "IP Range" value of the "default-allow-ssh" GCP firewall rule. For example, 45.56.122.7/32 and 208.43.25.31/32.

Related


How do I set it up so I can SSH into my VMWare guest VM?

Derek Thurn Documentation for this process on the internet is very lacking or outdated for some reason. Basically, I have a guest VMWare virtual machine in VMWare Fusion (running Ubuntu 10.10) and I'm hosting Mac OSX 10.6. I'd like to be able to SSH from a Mac

How do I set it up so I can SSH into my VMWare guest VM?

Derek Thurn Documentation for this process on the internet is very lacking or outdated for some reason. Basically, I have a guest VMWare virtual machine in VMWare Fusion (running Ubuntu 10.10) and I'm hosting Mac OSX 10.6. I'd like to be able to SSH from a Mac

Google VM Instant - Can't access SSH

Jeff I have installed ERPNext from Google Click to Deploy since 6 months ago and with that software it worked until last week until I lost access to the system and SSH When connecting using SSH, the system shows that connecting through the Cloud Identity-Aware

Google VM Instant - Can't access SSH

Jeff I've installed ERPNext from Google Click to Deploy since 6 months ago and with that software it worked until last week until I lost access to the system and SSH When connecting using SSH, the system shows that connecting through the Cloud Identity-Aware p

Google VM Instant - Can't access SSH

Jeff I have installed ERPNext from Google Click to Deploy since 6 months ago and with that software it worked until last week until I lost access to the system and SSH When connecting using SSH, the system shows that connecting through the Cloud Identity-Aware

Google VM Instant - Can't access SSH

Jeff I've installed ERPNext from Google Click to Deploy since 6 months ago and with that software it worked until last week until I lost access to the system and SSH When connecting using SSH, the system shows that connecting through the Cloud Identity-Aware p

I can't SSH into my Ubuntu VM

Unais221 So I went through the notes and tried to install an Oracle virtual machine that could run Ubuntu. Also, I'm having issues with SSH and the long details of the setup process are a bit vague. But I think I did it correctly, mainly setting the sshd_confi

I can't SSH into my Ubuntu VM

Unais221 So I went through the notes and tried to install an Oracle virtual machine that could run Ubuntu. Also, I'm having issues with SSH and the long details of the setup process are a bit vague. But I think I did it correctly, mainly setting the sshd_confi

How can I only allow access to the web server via SSH?

snow am My goal is to run a web server on a PC (running Ubuntu 16.04) that only I can access via SSH so that even people on the same network cannot access the lighttpd server. SSH is already set up, but I don't know what tool I would use to restrict lighttpd a

How can I only allow access to the web server via SSH?

snow am My goal is to run a web server on a PC (running Ubuntu 16.04) that only I can access via SSH so that even people on the same network cannot access the lighttpd server. SSH is already set up, but I don't know what tool I would use to restrict lighttpd a

How can I access a port on my local server via SSH?

cannonball I'm running a Flask server on a remote machine on the same network with an IP of 192.168.1.11. So the Flask server endpoint for the network should be 192.168.1.11:5000the default port 5000 chosen by flask. However, when I make a request from my loca

How can I access a port on my local server via SSH?

cannonball I'm running a Flask server on a remote machine on the same network with an IP of 192.168.1.11. So the Flask server endpoint for the network should be 192.168.1.11:5000the default port 5000 chosen by flask. However, when I make a request from my loca

Bluemix VM can't connect via SSH

Howard Liu As my thread states, I can't connect to the server via ssh, but I can connect to the server via Horizon. My region is USA. I tried CentOS 7 and Ubuntu 14.10 provided by Bluemix. I use a security group to enable all data (either ipv4 or ipv6, whateve

Bluemix VM can't connect via SSH

Howard Liu As my thread states, I can't connect to the server via ssh, but I can connect to the server via Horizon. My region is USA. I tried CentOS 7 and Ubuntu 14.10 provided by Bluemix. I use a security group to enable all data (either ipv4 or ipv6, whateve

How can I SSH to computer A via B SSH in one command?

Nicodi I want to access a computer, say machine A which is located in my university network . However, this computer is only accessible through the university's internal network, so I can't SSH into this computer directly from home. Here's what I'm doing now:

How can I SSH to computer A via B SSH in one command?

Nicodi I want to access a computer, say machine A which is located in my university network . However, this computer is only accessible through the university's internal network, so I can't SSH into this computer directly from home. Here's what I'm doing now: