Chit chat

———–

Allowing M$ into the linux foundation upsets me to no end.

Hello everybody out there using minix, linux, bsd, or etc –

I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 32 bit machines. This has been brewing since January, and is starting to get ready. I’d like any feedback on things people like/dislike in ‘nix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things). Building it using assembly language.

I’ve currently ported several programs, and things seem to work. This implies that I’ll get something practical within a few months or so, and I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise I’ll implement them 🙂

PS. Yes – it’s free of any ‘nix code, and it has a special fs. It is NOT portable (uses our own task switching etc), and it probably never will support anything other than traditional 32 bit equipment, as that’s all I have :-(.

———————————————————————–

 

Picture of Linux setup for SSH password less login.

 

Screenshot-Untitled Window.png

 

There are many times when I do not want to always keep typing in passwords to log into local servers. Not only that, I do not want to be typing passwords when people are watching.  If you run a primarily linux network like I do then this can be a real boon to your use of the systems not to have to do the traditional login. So we will need a way to authenticate to the systems we want to use..There was traditionally two kinds of authentication. RSA and DSA. RSA should not be used any more.  Public key authentication can only be established on a per system / user basis only i.e. it is not system wide. You will be setting up ssh with DSA public key authentication for SSH version 2 on two machines.Note: you will need to be able to use the command line/terminal for this project.Note: For both the server and the client port 22 should be changed to some number above 1024 that is an unused port.  Both numbers must be the same unless you are an advanced user,  Other settings should be changed as well. (i.e. disable root access)$ sudo vim /etc/ssh/sshd_config# Package generated configuration file
# See the sshd_config(5) manpage for details# What ports, IPs and protocols we listen for
Port 22The nmap command is a good way remotely to determine what ports are being used. You may like this instructable also:  http://www.instructables.com/id/Linux-screen-play/

Step 1: What do you need?
#1 machine : Client machine with ssh installed$ sudo apt-get update
$ sudo apt-get install ssh#2 machine: A remote server with ssh and openssh-server$ sudo apt-get update
$ sudo apt-get install ssh
openssh-serverNote: I usually add openssh-server to all machines except those I do not want there to be ssh access.

Step 2: Settin up the keys.

Picture of Settin up the keys.

 

Step #1: Generate DSA Key Pair

Use ssh-keygen command as follows:
$ ssh-keygen -t dsa
Output:

Enter file in which to save the key (/home/usernane/.ssh/id_dsa):  Press [Enter] key
Enter passphrase (empty for no passphrase): myPassword
Enter same passphrase again: myPassword
Your identification has been saved in /home/username/.ssh/id_dsa.
Your public key has been saved in /home/username/.ssh/id_dsa.pub.
The key fingerprint is:
04:be:15:ca:1d:0a:1e:e2:a7:e5:de:98:4f:b1:a6:01 username@username-desktop

Caution: a) Please enter a passphrase different from your account password and confirm the same.
b) The public key is written to /home/you/.ssh/id_dsa.pub.
c) The private key is written to /home/you/.ssh/id_dsa.
d) It is important you never-ever give out your private key.


Step 3: Directory set up and key copy to server.

Picture of Directory set up and key copy to server.

 

Set directory permission Next make sure you have correct permission on .ssh directory:
$ cd
$ chmod 700 .ssh
Update note: Must have been thinking about wev serverdirectory  permissions 755 s/b 700.t

Typically you want the .ssh directory permissions to be 700 (drwx——) and the public key (.pub file) to be 644 (-rw-r–r–). Your private key (id_rsa) should be 600 (-rw——-).

Copy public key.

Now copy file ~/.ssh/id_dsa.pub on Machine #1 (tom) to remote server as ~/.ssh/authorized_keys. The command scp is an ssh based  network file copy command and it will copy your public key file in this step. (you will be asked your your password on the server to log in.
$ scp ~/.ssh/id_dsa.pub user@server:.ssh/authorized_keysNote: You can get to the calculator from here:
http://www.onlineconversion.com/html_chmod_calculator.htm

Step 4: Server Side.

Picture of Server Side.

 

Now that you have the public key copied over to the server, you need to move it to the right place.
What you just did frim the client machine.$ scp ~/.ssh/id_dsa.pub user@bennjerrys:.ssh/authorized_keysWarning: If you already have an authorized_keys file this will write over it. (safer way)From client machine
$ scp ~/.ssh/id_dsa.pub user@bennjerrys:.
Server side.
$ cat
id_dsa.pub >> .ssh/authorized_keysChange permissions so only you can see and access it.$ chmod 600 ~/.ssh/authorized_keysNote: An authorized_key file (no “s” at the end)  is for the old rsa keys.

Step 5: Back to the client.

Picture of Back to the client.

 

So you do not have to enter in a passphrase:Type the following command at shell prompt:
$ exec /usr/bin/ssh-agent $SHELL
$ ssh-add

Step 6: Loggin in.

Picture of Loggin in.

 

Screenshot-- on oesrvr1 - File Browser.png

 

From the command line you could use:$ ssh user@servernameor$ ssh user@remote-server.comor$ scp file user@servername:/tmpNow if you try to logon in from the client to get to a share, you should not get a second password window.
Screenshot-eddie@oesrvr1.comcast.net: ~-3.png

Tada!!


Step 7: Advanced.

Picture of Advanced.

 

Almost forgot about this script:

<pre class="brush: plain;">#!/bin/bash
#
## USAGE: add_to_server.sh remote_server
#
## This script will add your ssh dsa public key to remote_server's authorized_keys list,
## assuming that everything is in it's default location
#
set -v     # verbose output
username="USERNAME"  # CHANGE ME!!!!
remote_server=$1  # assigns the first commandline argument to $remote_server
#
#
## Pipe the public key to ssh, then remotely touch the file to make sure it will be there, and concat to the end of it.
## Might work without the touch?
cat ~/.ssh/id_dsa.pub | ssh ${username}@${remote_server} "touch ~/.ssh/authorized_keys &amp;amp;&amp;amp; cat - &amp;gt;&amp;gt; ~/.ssh/authorized_keys"
#
exit 0

Step 8:

Picture of

 

One of the things most people hate to do is to type in passwords. Not only could someone be looking over your shoulder, but also the password gets sent where it can be easily monitored. There has to be a better way. A method very much used on ‘nix systems (including OS/X) is called the ‘secure shell’ (ssh for short). You can actually use it on Microsoft systems also, but it requires more than usual extra setup.
$ ssh typo1
password: _
Anyway, if you are setting up a new system and or recovering from a hard disk crash, setting up the ssh keys to all the servers or systems you log into can be a lot of fun. There had to be a way of automating this process.  The process is usually just three steps. Copy your key to the new server, adding the key to the authorized_key files, and then lastly removing the copied key if need be. So let’s make a batch file to take care of this.Installkey.sh

# invoke with ./Installkey.sh servername
# copy the key
scp .ssh/id_dsa.pub $1:~/.
# install the key
ssh $1 'cat id_dsa.pub &gt;&gt; .ssh/authorized_keys'
# remove the public key you just copied
ssh $1 'rm ~/id_dsa.pub'

Save it to an ascii file.
Enable the shell file
$ chmod +x  Installkey.sh

Run the code:

$ ./Installkey.sh typo1

Now you should be able to log into the server without typing a password.

$ ssh typo1
Linux typo1 2.6.32-5-686 #1 SMP Sun May 6 04:01:19 UTC 2012 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Debian comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

/)
o                 /’ )
/’   (                          ,.
__/’     )                        .’ `;
o      _.-~~~~’          “—..__             .’   ;
_.–‘  b)                       “–…____.’   .’
(     _.      )).      `-._                     <
`\|\|\|\|)-…..___.-     `-.         __…–‘-.’.
`—……____…—`.___.’—-… .’         `.;
`-`             `

This machine is for the exclusive use of OE.
Anyone attempting to gain, or gaining access other
than as specifically authorized will be prosecuted
under all applicable statutes plus all applicable
civil rules for damages.

————————————————————————
You have mail.
Last login: Sun Aug 19 05:15:37 2012 from oedt01
$ _

But then I thought, what I need to do a bunch of servers, even that could be tedious. So let’s add some more code. First we need to make a list of the servers we want to update and save them to a file.

servers:
[data]
typo1
oesrvr1

[/data]

Now we need to use the original code and add a routine to read the server names from a file. That allows us to just type in one command and do all the servers. If we need to add a new server to the list, you just add it to the servers file. One bit of caution is that if you have run the program before, you do not need to do it again on prepared servers. Rename the existing servers file and start a new servers file.

srvrsshupdate.sh:

####################################
# Update remote ssh server keys
# by the sysadmin
# date: 08/19/2012
#=================================
# Assignments
# --------------------------------
# servers has list of servers to update (s/b 1 server name per line)
servernamefile="servers"
# end assignments
#=================================
#
# Just do it. (main loop)
#---------------------------------
while read line
do server= $line
scp .ssh/id_dsa.pub $server:~/.
ssh $server 'cat id_dsa.pub &gt;&gt; .ssh/authorized_keys'
ssh $server 'rm ~/id_dsa.pub'
done &lt; $servernamefile
# end of main loop
#==================================
# End of job
###################################

Alternative code:


# invoke with ./Installkey.sh servername

# set up the .ssh dir if it does not exists
DIRECTORY=",ssh"
ssh $1 'if [ ! -d "$DIRECTORY" ];&nbsp; then&nbsp; mkdir $DIRECTORY ;chmod 700 $DIRECTORY ; fi'

# copy the key
scp $DIRECTORY/id_dsa.pub $1:~/.

# install the key
ssh $1 'cat id_dsa.pub &gt;&gt; $DIRECTORY/authorized_keys'
ssh $1 'chmod 600 $DIRECTORY/authorized_keys '

# remove the public key you just copied
ssh $1 'rm ~/id_dsa.pub'

Enable
$ chmod +x srvrsshupdate.sh
Run it
$ srvrsshupdate.shMy desktop bit the dust  I decieded to put a new install of linux (Debian replaced Ubuntu.) You really should not use old ssh keys, so I regenerated a new key and proceeded to update all the servers.

Step 9.

Picture of

 

One of the things I use so much that I tend to forget about is running command remotely. For example I want to start up a lighting sequence on a remote machine it can be as simpple/ Do that can be as ssh servername “commandinquotes”

$ ssh oesrvr1 “kitt”

 ——————————————————————

Vga cards are slowly being replaced by HDMI interfaces. What a lot of people do not know is that some vga cards come with a special port that allows us to attach devices known as i2c (I squared c) to the vga cards. That allows a personal computer to be attached to a host of devices from all kinds of sensors to other input devices. In fact you can connect Arduinos and other microprocessors to the vga port. Since most traditional personal computer motherboards allow the attachment of more than one vga card to the system, that allows for some interesting setups.

Data is sent and received over two wires (aka serial) to make interfacing rather easy.  Temperature sensors can be interfaced to the vga ports to detect dangerous sutuations insde and outside servers or other valuable equipment. The SDA and SCL connections are the key points of interaction.

If we can connect sensor devices to the vga port, they we can go one step further and add microprocessors to control other devices. One such device that might be used is the ever popular Arduino. At the retail level, most Arduinos are sold on an interface board, but you can also use them as standalone chips. Now legacy personal computers are infinitely more valuable for the time being with the added power of the microprocessors.
There is enough information on the Arduino, that I should not have to elaborate here, The sky is the limit. What’s your next project?
——————————————————————

Simple usb charger. try at your own risk,

——————————————————————

Simple blinker or flasher. No fancy ic’s (integrated circuits) are required.

Transistor: (NPN)
2n3904

For an alternate light blinker (like at a railroad crossing) you might try:

 

——————————————————————

Parcon is a neat little program that when used with sudo or the  like can control the data lines on the parallel port to turn on and off an led or other equipment using proper circuitry. (5 volts only otherwise)

Youtube video

https://www.youtube.com/watch?v=BlCHGiG_CQM

Parallel port.

pin 2 – data line 1  D0   –led–resistor— pin 18
pin 3 – data line 2  D1    ”
pin 4 – data line 3  D2    ”
pin 5 – data line 4  D3    ”
pin 6 – data line 5  D4    ”
pin 7 – data line 6  D5    ”
pin 8 – data line 7  D6    ”
pin 9 – data line 8  D7    ”
pin 18 – ground

To compile:
$ gcc parcon.c -o parcon

To run (l is off and h is on.)
$ sudo parcon 1l 2l 3h 5h 8l

Turns off pins 1,2, and 8. Tuns on pins 3 and 5/

parcon.c ( you will have to trim out the html code. I will try to fix it later.)

#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/ioctl.h&gt;
#include &lt;sys/io.h&gt;

char *binprint( unsigned char x, char *buf )
{
&nbsp; int i;
&nbsp; for( i=0; i&lt;8; i++ )
&nbsp;&nbsp;&nbsp; buf[7-i]=(x&amp;(1&lt;&lt;i))?'1':'0';
&nbsp; buf[8]=0;
&nbsp; return buf;
}

int main( int argc, char *argv[] )
{
&nbsp; char c;
&nbsp; unsigned char val;
&nbsp; char buf[9];
&nbsp; int x;
&nbsp; if( argc&lt;2 )
&nbsp; {
&nbsp;&nbsp;&nbsp; printf("&nbsp; example usage: parcon 1l 2l 3h 5h 8l\n");
&nbsp;&nbsp;&nbsp; return 2;
&nbsp; }
&nbsp; if( ioperm(888,1,1) )
&nbsp; {
&nbsp;&nbsp;&nbsp; printf("Couldn't get port 888\n");
&nbsp;&nbsp;&nbsp; return 1;
&nbsp; }
&nbsp; val = inb(888);
&nbsp; printf("old = %s\n",binprint(val,buf));
&nbsp; for( x=1; x&lt;argc; x++ )
&nbsp;&nbsp;&nbsp; if( argv[x][1]!='h' )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val &amp;= ~(1&lt;&lt;(argv[x][0]-'1'));
&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val |= 1&lt;&lt;(argv[x][0]-'1');
&nbsp;
&nbsp; printf("new = %s\n",binprint(val,buf));
&nbsp; outb(val,888);
&nbsp; return 0;
}

——————————————————————

Savory  crespelle.

P000-259-318-642-c3022

Good day.

Advertisements