Installing And Sharing HDD Partition via SSH
Ever wondered how to install and share your new hard drive with ssh over the internet? Here’s how to do it on Ubuntu Server 10.04 LTS.
- Format the drive to FAT32 or NTSC if you’re going to use it for files larger than 4GB.
- Connect your hard drive to the server
don’t forget to turn it off first when installing an internal drive, if it’s a usb just plug it in. - Next we need to check which device is the new hdd.
sudo fdisk -l
Disk /dev/sda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000d57dDevice Boot Start End Blocks Id System
/dev/sda1 * 1 9921 79687680 83 Linux
/dev/sda2 9921 10012 728065 5 Extended
/dev/sda5 9921 10012 728064 82 Linux swap / SolarisDisk /dev/sdc: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000413e2Device Boot Start End Blocks Id System
/dev/sdc1 1 182401 1465136001 7 HPFS/NTFS
In the list above we see that the device /dev/sdc1 is the one we want to mount.
Now that we know which device we’re going to use, we need to create the directory (mount location). After that we’re going to mount the /dev/sdc to that location. So when we enter the newly created dir it’s going to have the contents of the drive.
sudo mkdir /mnt/wd15
sudo vi /etc/fstabadd the following line in the fstab file
/dev/sdc1 /mnt/wd15 ntfs-3g defaults,locale=en_US.utf8 0 0
sudo mount /mnt/wd15
Now we’ve mounted /dev/sdc1 (our external drive) to /mnt/wd15. Every time system starts up the hdd will auto mount.
You’re about to be done, just mount the drive on your ubuntu desktop.
Just go to PLACES -> CONNECT TO SERVER -> service type=ssh, server=<<your_ip>>,port=22(default),folder=/mnt/wd15, name=<<username>>,BookmarkName=<<name_of_the_drive>>(optional)
Trouble shooting:
If you get the shared key error just delete it from ~/.ssh/known_hosts on the client machine or delete the file itself.
Ubuntu Server 10.04 LTS – DHCP Server
- So you’ve set up a network with your ubuntu server box and shared your internet or something…
You’re not satisfied to enter a static ip on every machine on your network? Well here’s what you need to do:
You need to install a DHCP server so every time a new network device is connected to your local network it automatically gets an IP address.
- Here’s how:
sudo apt-get install dhcp3-server
vi /etc/dhcp3/dhcpd.conf
- Edit your /etc/dhcpd3/dhcpd.conf file to match your taste.
- Here’s my config (just the lines that are not commented and if my local ip is 192.168.17.1 and network name gryphon)
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages (‘none’, since DHCP v2 didn’t
# have support for DDNS.)
ddns-update-style none;# option definitions common to all supported networks…
option domain-name “vityobug.com”;
option domain-name-servers 192.168.17.1;default-lease-time 600;
max-lease-time 7200;# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;# A slightly different configuration for an internal subnet.
subnet 192.168.17.0 netmask 255.255.255.0 {
range 192.168.17.10 192.168.17.30;
# option domain-name-servers ns1.internal.example.org;
option domain-name “gryphon.vityobug.com”;
option routers 192.168.17.1;
option broadcast-address 192.168.17.255;
default-lease-time 600;
max-lease-time 7200;
- Edit the next file to match your LOCAL network interface (eth0 in the example)
vi /etc/default/dhcp3-server
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. “eth0 eth1″.
INTERFACES=”eth0″
That’s it. Just restart the machine if needed.
Ubuntu Server 10.04 LTS – NAT Router
How to share your internet connection with NAT to all or some of the computers on the same LAN.
In other words: “I want to make my old pc a hardware firewall and/or router which works flawlessly (depending on the hardware ;))
And maybe share some multimedia on the network later. How do i do that?”
note: uncomment means to remove the # sign in the beginning of the line
Let’s say /dev/eth1 is the interface used for WAN and /dev/eth0 is the LAN interface of your machine.
- So we’ll edit/add some entries to iptables:
vi /etc/sysctl.conf
- uncomment the following lines
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
- Next
vi /etc/rc.local
Add the following lines before exit0
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables –table nat -A POSTROUTING -0 eth1 -j MASQUERADE
Ubuntu Server 10.04 LTS: Setup Networking
How to set up the networking in ubuntu server 10.04 LTS, may work on other debian based distributions too:
We’re going to use vi or vim to edit the /etc/network/interfaces
- First make sure which of your interfaces is used for internet and which for local networking. Check what type and what is your ip (DHCP or STATIC).
Let’s say /dev/eth1 is the interface used for WAN and /dev/eth0 is the LAN interface of your machine.
- Now if you have static IP edit your /etc/network/interfaces
sudo vi /etc/network/intrerfaces
# 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 eth1
iface eth1 inet static
address 17.252.169.74
netmask 255.255.255.0
network 17.252.169.0
broadcast 17.252.169.255
gateway 17.252.169.1
dns-nameservers 80.80.128.161 80.80.128.193# The local network interface
auto eth0
iface eth0 inet static
address 192.168.12.1
netmask 255.255.255.0
network 192.168.12.0
broadcast 192.168.12.255
Now iface eth1 inet static can be changed to dhcp if you have a dynamic ip address and delete the other lines with options.
address is your ip address
netmask is your network mask (usualy 255.255.255.0 or 255.255.0.0)
network is your network address (just like your ip, but the last part is 0)
broadcast is your network’s broadcast address (just like your ip, but usualy ending on 255)
dns-nameservers are the DNS servers you’re using, you can enter up to 3 separated by space
gateway is the address of your internet gateway
- Next add the following line in the /etc/resolv.conf file
(change the numbers to your DNS addresses)
name server 80.80.128.161 80.80.128.193
- Restart the networking (or the system if needed):
sudo /etc/networking restart
- Next Step Is Optional:
- Test your connectivity by pinging some working ip address
ping 4.2.2.2
or
ping 8.8.8.8
or
ping google.com
If you have replies your network is working.
Debian/Ubuntu System Update
1st thing you have to do after you’ve installed the system and set up the networking is to install the most important updates:
sudo apt-get install update
sudo apt-get install upgrade
#type “yes” or “y” when asked
#restart if needed
New Posts Soon
Starting off new blog, posting about everything. Soon (when I have time)
Започвам на ново блога, да поствам за всичко. Скоро (когато намеря време)