Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, 8 November 2018

SSH from Linux

PuTTY is using different key format than the OpenSSH and OpenSSH is failing to report correctly the errors about unknown format in some versions.

If you want to use the PuTTY key in OpenSSH, you need to convert the private key to OpenSSH format in PuTTYGen (as described on SO):


AT PC:
Open PuttyGen
Click Load
Load your private key
Go to Conversions->Export OpenSSH and export your private key
Save it as ghouseam.ossh

THROUGH FTP:
Copy the above private key to /ppk

AT SERVER (ftp client):
ssh root@206.189.128.155 -i ghouseam-ossh

Increase Swap size in Linux

sudo swapon -s
sudo swapoff /extraswap
sudo fallocate -l 4G /extraswap
sudo mkswap /extraswap
sudo swapon /extraswap
sudo swapon -s

Configure Static IP Address on Linux VM in VMware Player


If you run VMware Player, you would have 3 networking options for virtual machines running there: Bridged, NAT, Host-Only. In the latest 5.0.1, I also found a new one: LAN Segment. This blog has a nice explanation on these three settings if you want to get more details.

In most of cases, I use NAT for networking because the virtual machine can have Internet access which allows me to install additional software as needed. By default, VMware Player uses DHCP to dynamically assign IP address while using NAT. So you cannot guarantee to get same IP address after each rebooting.

You can set static IP address for a VM running on VMware Player with a little trick. On a Debian Linux machine like Ubuntu, you can edit a configuration file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ sudo vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5)
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
  address 192.168.47.200
  netmask 255.255.255.0
  broadcast 192.168.47.255
  gateway 192.168.47.2
dns-nameservers 192.168.47.2

After saving the file, you would like to restart the network so that the change take effect:

1
$ sudo service networking restart

In my case, the VMnet8 which is the network adapter for the NAT network has an IP address of 192.168.47.1. When I first modified the interfaces file, I used it as the gateway IP address and failed to ping outside the network.

To figure it out why, I reversed back to the DHCP configuration (change the ifacce line to “iface eth0 dhcp” and delete the lines afterwards). In the DHCP mode, typing command “route –n” will show working gateway IP address: 192.168.47.2.

By default, the gateway IP is configured to use X.X.X.2. This can be changed with Virtual Network Editor which is not included in VMware Player. I will show you how to hack it in next post.