RSS
 

Posts Tagged ‘shell’

Setting up SSH keys

25 Jul

Sometimes you work with your remote host so much, that having to enter a password every time becomes a real pain. If that is the case, you should follow with this instructions to set up automatic handshake with your remote host.

First off, you have to have OpenSSH on both the host and your local machine. SSH into your remote host to create the “.ssh” directory in your home folder.

Now we are going to use the SSH Key Generator to create the authorized key.

ssh-keygen -t dsa

You will be prompted to enter a passphrase for this identity key. Choose something hard to break.

Now all you have to do is copy the identity key to the remote host.

scp ~/.ssh/id_dsa.pub myuser@remote.host.com:.ssh/authorized_keys2

Of course, you will replace “myuser@remove.host.com” with your actual remote host’s access information. Now, you will run a simple script that will tell the remote host which identity it should use, and also starts a new shell that will enable you to SSH to the remote host without entering any passwords.

ssh-agent sh -c 'ssh-add < /dev/null && bash'

Now try typing “ssh myuser@remote.host.com” and you will see that you are all set.

 

Using Linux Shell to Add a User

12 Jan

Hiya all. As I continued to work with my remote server’s shell, a new issue arose. I needed to add a new user to my system.

So, suppose that you want to add Mr. Friend to your system via bash:

useradd mrfriend

Okay, now you need to set a password for our friend:

passwd mrfriend

You will be prompted to enter the password and confirm it.

However, to do all this you need to be root. To do so, before entering any of these, type:

su -

Don’t forget the “-“, because otherwise you will get a “command not found” when you issue “useradd”.

Note: On some systems the command is “adduser” instead of “useradd”.