Stephen Fry

"Education is the sum of what students teach each other in between lectures and seminars. " - Stephen Fry
Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts

Tuesday, 8 January 2013

Quick Guide: Remotely adding a new user on Ubuntu 12.04

In the following is a quick guide to creating a new user (we will be calling this user "username") on a Amazon Cloud EC2 instance with Ubuntu 12.04 AMI

CREATING NEW USER

We will begin by adding the new user and setting the new users password

$ sudo adduser <username>

This command will then take you though the setting up a password. You can check the users that you now have my opening the /etc/passwd file

Now we are going to make use of a unix command called "visudo", this allow you to edit the sudoerrs file in a concurrent access safe way.  Before using visudo, we need to check that the default editor is the one that we would like and change it, if required:

$ sudo update-alternatives --config editor

Now you will be given a dialogue where you can select your favourite text editor.

$ visudo


Now add the following line to the file that has been opened:

<username> ALL=(ALL) ALL

Now exit the machine and log back in as ubuntu. 


You can now switch to this newly created user with 
$ su <username>
$ cd /home/<username>

GENERATING KEYS FOR SSH TO NEW USER

We are now going to generate the public key for public/private key pair that will be used later to SSH directly into this new user

$ ssh-keygen -b 1024 -f mykey -t dsa

This line has generated two files, the public key paws.pub and the private key paws. To be able to ssh from a local machine to the new paws user on this remote machine, we need to place copy the contence of paws.pub into /home/paws/.shh/authorized_keys and we need to have a copy of the private key (called paws) on the local machine


$ mkdir .ssh
$ chmod 700 .ssh
$ cat mykey.pub > .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys

Now that we have the key we need to transfer this key on to our local machine and generate the private key



$ sudo chown <username>:ubuntu .ssh
$ sudo cp mykey /home/ubuntu


$ sudo chown <username>:ubuntu .ssh/authorized_keys

$ sudo chmod 777 /home/ubuntu/mykey


Logout and return to local machine
$ scp -i originalkey.pem ubuntu@<URL-of-server>:/home/ubuntu/mykey mykey

Now you can ssh into your remote machine as this new user:

$ chmod 400 mykey $ ssh -i mykey <username>@url-of-server






Tuesday, 24 July 2012

Another Failed attempt to set up iperf on Andriod Phone - Demo Pt 4.1

Due to the issues with the Iperf application for android and part of the touch screen on my andriod phone not working properly, I've decided that it would be best to set up SSH to remote access on android phone, to make working with the phone easier.

To application that I decided to use to help get my SSH running on as quickly as possible was SSHDroid. This is an excellent application that I would highly recommend. The steps in setting up SSH access where:
  • Install SSHDroid and launch application
  • Change the password from its default which is "admin"
  • Install OpenSSH on your linux computer
  • run ssh root@<ip-address of android phone> 
  • Enter password when requested

Now I have the command line of the android phone, I downloaded iperf and extracted the contains of the .tar.gz file to the SD card. The next stage in my plan was to use ./configure then make then make install as per usual.

But as ever, thing are never that straight forward.
  • on doing ./configure, I get permission denied
  • on doing sudo ./configure, I get sudo: not found
  • on doing echo $USER, I get root
  • on doing ls -l | grep configure, I get ---xrwxr-x
so why will it not work ?

UPDATE:

I've managed to deal with the "Permission Denied" error despite having root access and the correct permission by prefixing ./configure with sh. This then fails to compile due to the lack of a C++ compiler