SSH, PTS and TTY page index
This is the current content sections of the page: SSH, DSH, SCP


Difference between Shell, Console and Terminal:
The terminal connects to the console where the shell is presented.
A TTY is a teletypewriter. It is essentially the equivalent of the console port but is often virtualized in software. If you jump to a different virtual console on your Linux machine using ctrl+alt+f1 to 12 combination and login in, you can see the multiple consoles with logged in users by running the who command. Then there are PTS devices which are Pseudo Terminal Slaves, a virtual device of sorts. They are a form of TTY, but one that is emulated to allow a TTY connection over a network or some other means. SSH and Telnet are good examples of programs that use PTS devices.

SSH: Tunneling

To use local forwarding, connect to the SSH server normally, but also supply the -L argument.
The syntax is:
ssh -L local_port:remote_address:remote_port For example, let’s say the database server at your office is located at on the office network. You have access to the office’s SSH server at , and your user account on the SSH server is bob . In that case, your command would look like this:
ssh -L 8888: SSH Agent:
eval `ssh-agent -s` & ssh-add Add to your Bash config file:
SSHAGENT=/usr/bin/ssh-agent SSHAGENTARGS="-s" if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then eval `$SSHAGENT $SSHAGENTARGS` trap "kill $SSH_AGENT_PID" 0 fi This will start an agent automatically for each new command prompt window that you open (which is suboptimal if you open multiple command prompts in one session, but at least it should work).

SSH Key Management

Add a passphrase to a key generated without:
ssh-keygen -p -f keyfile Remove a passphrase from a key:
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile] Leave the new_passphrase blank.
Fun ssh command:
for s in $(cat server-cluster); \ do ssh -i $PRIVATE_KEY USER_NAME@$s "sudo su -c 'cd /root/dockerComposeWebServer && \ docker-compose down && docker-compose up -d'";done


Server Group: /etc/dsh/group/
options : -f machinefile : Add all machines found in the specified file to the list of machines that the specified command is executed. -g groupname : Add all machines found in /etc/dsh/group/groupname to the list of machines that the specified command is executed. -w : Executes on each machine and waits for the execution finishing before moving on to the next machine. -c : Executes shell concurrently. -M : Prepends machine names on the standard output. Useful to be used in conjunction with the --concurrent-shell option so that the output is slightly more parsable. Examples:
dsh -g POOL_Dir/Server_Group_File "df -h /" dsh -c -m $(grep serverSname* /etc/dsh/group/pool/servers_types|perl -pe 'print "," if($i++);chomp;') \ '/users/dev/ /logs/script.pl_log- 20181202[5-9]* /logs/script.pl_log'



Copy the file "foobar.txt" from a remote host to the local host:
scp /some/local/directory Copy the file "foobar.txt" from the local host to a remote host:
scp foobar.txt Copy the directory "foo" from the local host to a remote host's directory "bar":
scp -r foo Copy the file "foobar.txt" from remote host "" to remote host "":
scp \ Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host:
scp foo.txt bar.txt Copy the file "foobar.txt" from the local host to a remote host using port 2264:
scp -P 2264 foobar.txt Copy multiple files from the remote host to your current directory on the local host:
scp\{a,b,c\} . scp\{foo.txt,bar.txt\} .


By default scp uses the Triple-DES cipher to encrypt the data being sent. Using the Blowfish cipher has been shown to increase speed. This can be done by using option -c blowfish in the command line.:
scp -c blowfish some_file It is often suggested that the -C option for compression should also be used to increase speed. The effect of compression, however, will only significantly increase speed if your connection is very slow. Otherwise it may just be adding extra burden to the CPU. An example of using blowfish and compression::
scp -c blowfish -C local_file