Blog Archive

Saturday, February 12, 2011

ssh login without password

To enable the remote login you create a pair of keys, one of which you simply append to a file upon the remote system. When this is done you'll then be able to login without being prompted for a password - and this also includes any cronjobs you have setup to run.

If you don't already have a keypair generated you'll first of all need to create one.

If you do have a keypair handy already you can keep using that, by default the keys will be stored in one of the following pair of files:

  • ~/.ssh/identity and ~/.ssh/identity.pub
    • (This is an older DSA key).
  • ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub
    • (This is a newer RSA key).

If you have neither of the two files then you should generate one. The DSA-style keys are older ones, and should probably be ignored in favour of the newer RSA keytypes (unless you're looking at connecting to an outdated installation of OpenSSH). We'll use the RSA keytype in the following example.

To generate a new keypair you run the following command:

source@lappy:~$ ssh-keygen -t rsa

This will prompt you for a location to save the keys, and a pass-phrase:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/source/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/source/.ssh/id_rsa.
Your public key has been saved in /home/source/.ssh/id_rsa.pub.

If you accept the defaults you'll have a pair of files created, as shown above, with no passphrase. This means that the key files can be used as they are, without being "unlocked" with a password first. If you're wishing to automate things this is what you want.

Now that you have a pair of keyfiles generated, or pre-existing, you need to append the contents of the .pub file to the correct location on the remote server.

Assuming that you wish to login to the machine called destination from your current host with the id_rsa and id_rsa.pub files you've just generated you should run the following command:

ssh-copy-id -i ~/.ssh/id_rsa.pub username@destination

This will prompt you for the login password for the host, then copy the keyfile for you, creating the correct directory and fixing the permissions as necessary.

The contents of the keyfile will be appended to the file ~/.ssh/authorized_keys2 for RSA keys, and ~/.ssh/authorised_keys for the older DSA key types.

Once this has been done you should be able to login remotely, and run commands, without being prompted for a password:

source@lappy:~$ ssh destination uptime
09:52:50 up 96 days, 13:45, 0 users, load average: 0.00, 0.00, 0.00
What if it doesn't work?

There are three common problems when setting up passwordless logins:

  • The remote SSH server hasn't been setup to allow public key authentication.
  • File permissions cause problems.
  • Your keytype isn't supported.

Each of these problems is easily fixable, although the first will require you have root privileges upon the remote host.

If the remote server doesn't allow public key based logins you will need to updated the SSH configuration. To do this edit the file /etc/sshd/sshd_config with your favourite text editor.

You will need to uncomment, or add, the following two lines:

RSAAuthentication yes
PubkeyAuthentication yes

Once that's been done you can restart the SSH server - don't worry this won't kill existing sessions:

/etc/init.d/ssh restart

File permission problems should be simple to fix. Upon the remote machine your .ssh file must not be writable to any other user - for obvious reasons. (If it's writable to another user they could add their own keys to it, and login to your account without your password!).

If this is your problem you will see a message similar to the following upon the remote machine, in the file /var/log/auth:

Jun  3 10:23:57 localhost sshd[18461]: Authentication refused: 
bad ownership or modes for directory /home/source/.ssh

To fix this error you need to login to the machine (with your password!) and run the following command:

cd
chmod 700 .ssh

Finally if you're logging into an older system which has an older version of OpenSSH installed upon it which you cannot immediately upgrade you might discover that RSA files are not supported.

In this case use a DSA key instead - by generating one:

ssh-keygen

Then appending it to the file ~/.ssh/authorized_keys on the remote machine - or using the ssh-copy-id command we showed earlier.

Note if you've got a system running an older version of OpenSSH you should upgrade it unless you have a very good reason not to. There are known security issues in several older releases. Even if the machine isn't connected to the public internet, and it's only available "internally" you should fix it.


Instead of using authorized_keys/authorized_keys2 you could also achieve a very similar effect with the use of the ssh-agent command, although this isn't so friendly for scripting commands.

This program allows you to type in the passphrase for any of your private keys when you login, then keep all the keys in memory, so you don't have password-less keys upon your disk and still gain the benefits of reduced password usage.

If you're interested read the documentation by running:
man ssh-agent

Thanks Steve for this great Tip


Sunday, February 6, 2011

system admin commands windows

Basic System Administration Commands for windows

Control Panel
    * CONTROL: opens the control panel window
    * CONTROL ADMINTOOLS: opens the administrative tools
    * CONTROL KEYBOARD: opens keyboard properties
    * CONTROL COLOUR: opens display properties.Appearance tab
    * CONTROL FOLDERS: opens folder options
    * CONTROL FONTS: opens font policy management
    * CONTROL INTERNATIONAL or INTL.CPL: opens Regional and Language option
    * CONTROL MOUSE or MAIN.CPL: opens mouse properties
    * CONTROL USERPASSWORDS: opens User Accounts editor
    * CONTROL USERPASSWORDS2 or NETPLWIZ: User account access restrictions
    * CONTROL PRINTERS: opens faxes and printers available
    * APPWIZ.CPL: opens Add or Remove programs utility tool
    * OPTIONALFEATURES: opens Add or Remove Windows component utility
    * DESK.CPL: opens display properties. Themes tab
    * HDWWIZ.CPL: opens add hardware wizard
    * IRPROPS.CPL: infrared utility tool
    * JOY.CP: opens game controllers settings
    * MMSYS.CPL: opens Sound and Audio device Properties. Volume tab
    * SYSDM.CPL: opens System properties
    * TELEPHON.CPL: Opens phone and Modem options
    * TIMEDATE.CPL: Date and Time properties
    * WSCUI.CPL: opens Windows Security Center
    * ACCESS.CPL: opens Accessibility Options
    * WUAUCPL.CPL: opens Automatic Updates
    * POWERCFG.CPL: opens Power Options Properties
    * AZMAN.MSC: opens authorisation management utility tool
    * CERTMGR.MSC: opens certificate management tool
    * COMPMGMT.MSC: opens the Computer management tool
    * COMEXP.MSC or DCOMCNFG: opens the Computer Services management tool
    * DEVMGMT.MSC: opens Device Manager
    * EVENTVWR or EVENTVWR.MSC: opens Event Viewer
    * FSMGMT.MSC: opens Shared Folders
    * NAPCLCFG.MSC: NAP Client configuration utility tool
    * SERVICES.MSC: opens Service manager
    * TASKSCHD.MSC or CONTROL SCHEDTASKS: opens Schedule Tasks manager
    * GPEDIT.MSC: opens Group Policy utility tool
    * LUSRMGR.MSC: opens Local Users and Groups
    * SECPOL.MSC: opens local security settings
    * CIADV.MSC: opens indexing service
    * NTMSMGR.MSC: removable storage manager
    * NTMSOPRQ.MSC: removable storage operator requests
    * WMIMGMT.MSC: opens (WMI) Window Management Instrumentation
    * PERFMON or PERFMON.MSC: opens the Performance monitor
    * MMC: opens empty Console
    * MDSCHED: opens memory diagnostics tools
    * DXDIAG: opens DirectX diagnostics tools
    * ODBCAD32: opens ODBC Data source Administrator
    * REGEDIT or REGEDT32: opens Registry Editor
    * DRWTSN32: opens Dr. Watson
    * VERIFIER: opens Driver Verifier Manager
    * CLICONFG: opens SQL Server Client Network Utility
    * UTILMAN: opens Utility Manager
    * COLORCPL: opens color management
    * CREDWIZ: back up and recovery tool for user passwords
    * MOBSYNC: opens Synchronization center
    * MSCONFIG: opens System Configuration Utility
    * SYSEDIT: opens System Configuration Editor (careful while using this command)
    * SYSKEY: Windows Account Database Security management (careful while using this command)
 
Windows utility and applications
 
    * EXPLORER: Opens windows Explorer
    * IEXPLORER: Opens Internet explorer
    * WAB: opens Contacts
    * CHARMAP: opens Character Map
    * WRITE: opens WordPad
    * NOTEPAD: opens Notepad
    * CALC: opens Calculator
    * CLIPBRD: opens Clipbook Viewer
    * WINCHAT: opens Microsoft Chat Interface
    * SOUNDRECORDER: opens sound recording tool
    * DVDPLAY: run CD or DVD
    * WMPLAYER: opens Windows Media Player
    * MOVIEMK: Opens untitled Windows Movie Maker
    * OSK: opens on-screen Keyboard
    * MAGNIFY: opens Magnifier
    * WINCAL: opens Calendar
    * DIALER: opens phone Dialer
    * EUDCEDIT: opens Private Character Editor
    * NDVOL: opens the mixer volume
    * RSTRUI : opens Tool System Restore (For Vista only)
    * %WINDIR%\SYSTEM32\RESTORE\rstrui.exe: opens Tool System Restore (for XP only).
    * MSINFO32: Opens the System Information
    * MRT : launches the utility removal of malware.
    * Taskmgr : Opens the Windows Task Manager
    * CMD: opens a command prompt
    * MIGWIZ: Opens the tool for transferring files and settings from Windows (Vista only)
    * Migwiz.exe: Opens the tool for transferring files and settings from Windows (for XP only)
    * SIDEBAR: Open the Windows (Vista only)
    * Sigverif : Opens the tool for verification of signatures of files
    * Winver : Opens the window for your Windows version
    * FSQUIRT: Bluetooth Transfer Wizard
    * IExpress opens the wizard for creating self-extracting archives. Tutorial HERE
    * MBLCTR: opens the mobility center (Windows Vista only)
    * MSRA : Opens the Windows Remote Assistance
    * Mstsc : opens the tool connection Remote Desktop
    * MSDT: opens the diagnostic tools and support Microsoft
    * WERCON: opens the reporting tool and solutions to problems (for Vista only)
    * WINDOWSANYTIMEUPGRADE: Enables the upgrade of Windows Vista
    * WINWORD : opens Word (if installed)
    * PRINTBRMUI : Opens migration wizard printer (Vista only)
 
Disk management
 
    * DISKMGMT.MSC: opens disk management utility
    * CLEANMGR: opens disk drive clean up utility
    * DFRG.MSC: opens disk defragmenter
    * CHKDSK: complete analysis of disk partition
    * DISKPART: disk partitioning tool
 
Connection management
 
    * IPCONFIG: list the configuration of IP addresses on your PC (for more information type IPCONFIG/? in the CMD menu)
    * INETCPL.CPL: opens internet properties
    * FIREWALL.CPL: opens windows firewall
    * NETSETUP.CPL: opens network setup wizard
 
Miscellaneous commands
 
    * JAVAWS: View the cover of JAVA software (if installed)
    * AC3FILTER.CPL: Opens the properties AC3 Filter (if installed)
    * FIREFOX: Mozilla launches Firefox (if installed)
    * NETPROJ: allow or not connecting to a network projector (For Vista only)
    * LOGOFF: closes the current session
    * SHUTDOWN: shut down Windows
    * SHUTDOWN-A: to interrupt Windows shutdown
    * %WINDIR% or %SYSTEMROOT%: opens the Windows installation
    * %PROGRAMFILES%: Opens the folder where you installed other programs (Program Files)
    * %USERPROFILE%: opens the profile of the user currently logged
    * %HOMEDRIVE%: opens the browser on the partition or the operating system is installed
    * %HOMEPATH%: opens the currently logged user C: \ Documents and Settings \ [username]
    * %TEMP%: opens the temporary folder
    * VSP1CLN: deletes the cache for installation of the service pack 1 for Vista
    * System File Checker (Requires Windows CD if the cache is not available):
          o SFC / scannow: immediately scans all system files and repairs damaged files
          o SFC / VERIFYONLY: scans only those files system
          o SFC / Scanfil = "name and file path": scans the specified file, and repaired if damaged
          o SFC / VERIFYFILE = "name and file path": Scans only the file specified
          o SFC / scanonce: scans the system files on the next restart
          o SFC / REVERT: return the initial configuration (For more information, type SFC /? In the command prompt CMD.
 

Add/Remove Programs = appwiz.cpl
Administrative Tools = control admintools
Authorization Manager= azman.msc "New"
 
Calculator = calc
Certificate Manager = certmgr.msc
Character Map = charmap
Check Disk Utility = chkdsk
Control Panel = control "New"
Command Prompt = cmd.exe
Component Services = dcomcnfg
Computer Management = compmgmt.msc = CompMgmtLauncher "New"
 
Date and Time Properties = timedate.cpl
Downloads = Downloads "New"
Device Manager = devmgmt.msc
Direct X Troubleshooter = dxdiag
Disk Cleanup Utility = cleanmgr
Defragment User Interface = dfrgui "New"
Ditilizer Calibration Tool = tabcal "New"
Disk Management = diskmgmt.msc
Disk Parmelonion Manager = diskpart
Display Properties = control desktop or desk.cpl
DPI Scaling = dpiscaling "New"
Driver Package Installer = dpinst "New"
Driver Verifier Utility = verifier or /reset
DVD Player = dvdplay "New"
 
Encryption File System = rekeywiz "New"
Event Viewer = eventvwr.msc
 
Fax Cover Sheet Editor = fxscover "New"
File Signature Verification Tool = sigverif
Folders Properties = control folders
Fonts = control fonts
Free Cell Card Game = freecell
 
Group Policy Editor = gpedit.msc
 
Internet Explorer = iexplore
Iexpress Wizard = iexpress
Internet Properties = inetcpl.cpl
IP Configuration = ipconfig.exe
iSCSI Initiator = iscsicpl "New"
 
Keyboard Properties = control keyboard
 
Libraries = explorer or Windows key + E
Local Security Settings = secpol.msc
Local Users and Groups = lusrmgr.msc
Logs You Out Of Windows = logoff
 
Microsoft Support Diagnostic Tool = msdt "New"
Microsoft Paint = mspaint.exe
Mouse Properties = control mouse
Mouse Properties = main.cpl
Mobility Center (only on mobile) = mblctr or Windows key + X
Network Connections = control netconnections
Network Connections = ncpa.cpl
Notepad = notepad
 
ODBC Data Source Administrator = odbcad32 "New"
Optional Features Manager = optionalfeatures "New"
On Screen Keyboard = osk or Windows key + U
 
Performance Monitor = perfmon.msc
Phone and Modem Options = telephon.cpl
Power Configuration = powercfg.cpl
Printers and Faxes = control printers
Printer Migration = PrintBrmUi "New"
Private Character Editor = eudcedit
 
Regional Settings = intl.cpl
Registry Editor = regedit.exe
Remote Assistance = msra "New"
Remote Desktop = mstsc
Resultant Set of Policy = rsop.msc
 
Scheduled Tasks = control schedtasks
Security Center = wscui.cpl
Services = services.msc
Shared Folders/MMC = fsmgmt.msc
Shuts Down Windows = shutdown
Snipping Tool = snippingtool "New"
Sounds and Audio = mmsys.cpl
Sound Recorder = soundrecorder "New"
Sound Volume = sndvol "New"
Spider Solitare Card Game = spider
SQL Client Configuration = cliconfg
Stored User Names and Passwords = credwiz "New"
Sticky Note = StikyNot "New"
System Configuration Editor = sysedit
System Configuration Utility = msconfig
System File Checker Utility = sfc
System Information = msinfo32
System Properties = sysdm.cpl or Windows key + Pause/Break
 
Task Manager = taskmgr
Trusted Platform Module = TpmInit "New"
 
Utility Manager = utilman
User Accounts = netplwiz or control userpasswords2
 
Windows Activation = slui "New"
Windows Backup Utility = sdclt "New"
Windows Fax and Scan = wfs "New"
Windows Firewall = firewall.cpl
Windows Firewall with Advanced Security = wf.msc "New"
Windows Image Acquisition = wiaacmgr "New"
Windows Media Player = wmplayer
Windows Magnifier = magnify
Windows Management Infrastructure = wmimgmt.msc
Windows Update App Manager = wuapp "New"
Windows Standalong Update Manager = wusa "New'
Windows System Security Tool = syskey
Windows Share Creation Wizard = shrpubw "New"
Wordpad = write

Tuesday, February 1, 2011

Change MAC address debian

If you wish to explicitly set your MAC address upon a Debian system you can do so by adding an entry to your /etc/network/interfaces  file.

Beneath each interface you wish to setup add "hwaddress ether xx:xxx..". For example:

auto eth0 static
iface eth0 inet static
 address 1.2.3.4
 gateway ...
 broadcast ...
 hwaddress ether 02:01:02:03:04:08


Followers