OpenSSH / PuTTY / WinSCP / Key Authentication
PuTTY / WinSCP are a pair of Windows based tools that enable terminal access and file transfers over SSH protocol. The process below shows how to configure key file access control between you build system and a remote Windows system.
- Download and install fully Putty install
- Download and install full WinSCP install
- Open terminal session to system with Putty (to your Ubuntu build machine)
- Enter (with no passphrase):
cd .ssh ssh-keygen -t rsa -b 4096
- Copy the public key file to ‘authorized_keys’ in the .ssh directory.
- Edit ‘/etc/ssh/sshd_config’ and uncomment the AuthorizedKeysFile line and verify it points to user .ssh/authorized_keys.
- Restart ssh
sudo service ssh restart
- Use WinSCP to copy the public and private key to the client system.
- Use PuttyKeyGen to import the private key, and export as a putty key.
- Attach this putty private key to a session, and verify it works.
- Note: permissions on .ssh may be either 700 or 755, use as necessary to fix. Permissions on ‘authorized_keys may be 600 or 644, as necessary to work.
- Disable Password logins : Edit ‘/etc/ssh/sshd_config’ and uncomment “PasswordAuthentication” and set it to ‘no’.
- Restart the ssh service again, open a new session to confirm.
Reference
Screen
Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Each virtual terminal provides the functions of a DEC VT100 terminal and, in addition, several control functions from theISO 6429 (ECMA 48, ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.
Getting In
start a new screen session with session name | screen -S <name> |
list running sessions/screens | screen -ls |
attach to a running session | screen -r |
… to session with name | screen -r <name> |
the “ultimate attach” | screen -dRR (Attaches to a screen session. If the session is attached elsewhere, detaches that other display. If no session exists, creates one. If multiple sessions exist, uses the first one.) |
Escape key
All screen commands are prefixed by an escape key, by default C-a (that’s Control-a, sometimes written ^a). To send a literal C-a to the programs in screen, use C-a a.
Getting Out
detach | C-a d |
detach and logout (quick exit) | C-a D D |
exit screen | “C-a : quit” or exit all of the programs in screen. |
force-exit screen | C-a C-\ (not recommended) |
Window Management
create new window | C-a c |
change to last-visited active window | C-a C-a (commonly used to flip-flop between two windows) |
change to window by number | C-a <number> (only for windows 0 to 9) |
change to window by number or name | C-a ‘ <number or title> |
change to next window in list | C-a n or C-a <space> |
change to previous window in list | C-a p or C-a <backspace> |
see window list | C-a “ (allows you to select a window to change to) |
show window bar | C-a w (if you don’t have window bar) |
close current window | Close all applications in the current window (including shell) |
kill current window | C-a k (not recommended) |
kill all windows | C-a \ (not recommended) |
rename current window | C-a A |
Split Screen
split display horizontally | C-a S |
split display vertically | C-a | or C-a V (for the vanilla vertical screen patch) |
jump to next display region | C-a tab |
remove current region | C-a X |
remove all regions but the current one | C-a Q |
Scripting
send a command to a named session | screen -S <name> -X <command> |
create a new window and run ping example.com | screen -S <name> -X screen ping example.com |
stuff characters into the input buffer using bash to expand a newline character (from here) |
screen -S <name> [-p <page>] -X stuff $'quit\r' |
a full example |
# run bash within screen screen -AmdS bash_shell bash # run top within that bash session screen -S bash_shell -p 0 -X stuff $'top\r' # ... some time later # stuff 'q' to tell top to quit screen -S bash_shell -X stuff 'q' # stuff 'exit\n' to exit bash session screen -S bash_shell -X stuff $'exit\r' |
Miscellaneous
redraw window | C-a C-l |
enter copy mode | C-a [ or C-a <esc> (also used for viewing scrollback buffer) |
paste | C-a ] |
monitor window for activity | C-a M |
monitor window for silence | C-a _ |
enter digraph (for producing non-ASCII characters) | C-a C-v |
lock (password protect) display | C-a x |
enter screen command | C-a : |
Reference