If you want to connect to remote machine named othermachine as user named othermachineuser.
On your local machine you need to generate a private-public keypair using ssh-keygen as follows (You only need to do this once):
ssh-keygen -t dsa
This will create a private and public keypair which is stored in ~/.ssh directory.
Next run the following command once for every machine you want to remotely login without specifying password:
scp ~/.ssh/id_dsa.pub othermachineuser@othermachine:~/.ssh/authorized_keys
Now you can login to the machine using ssh without requiring to specify any password. Your public key, which you copied to the remote machine, is checked (not directly) against your private key to verify your authenticity.
On Linux or Unix Systems you can use sftp like this:
sftp -oPort=1234 firstname.lastname@example.org
After authenticating, the following commands can be used. Any paths should have quotes if they contain spaces. Some standard commands and their definitions for command line SFTP include: ? Get help on the use of SFTP commands. bye Close the connection to the remote computer and exit SFTP. cd Change the directory on the remote computer. chgrp Change the group associated with a computer file (chgrp system foofile). chmod Change the permissions of files on the remote computer. chown Change the owner of files on the remote computer. dir List the files in the current directory on the remote computer. exit Close the connection to the remote computer and exit SFTP. get Copy a file from the remote computer to the local computer. help Get help on the use of SFTP commands. lcd Change the directory on the local computer. lls See a list of the files in the current directory on the local computer. lmkdir Create a directory on the local computer. ln Create a symbolic link for a file on the remote computer. lpwd Show the current directory (present working directory) on local computer. ls Show the current directory on the remote computer. lumask Change the local umask value. mkdir Create a directory on the remote computer. progress Toggle display of progress meter. put Copy a file from the local computer to the remote computer. pwd Show the current directory (present working directory) on remote computer. quit Close the connection to the remote computer and exit SFTP. rename Rename a file on the remote host. rm Delete files from the remote computer. rmdir Remove a directory on the remote host (the directory has to be empty). symlink Create a symbolic link for a file on the remote computer. version Display the SFTP version. ! In Unix, exit to the shell prompt, where you can enter commands. Enter exit to get back to SFTP. If you follow ! with a command (e.g., !pwd), SFTP will execute the command without dropping you to the Unix prompt.
Creating an SSH Tunnel to my router at home.
ssh -N -L 8888:22.214.171.124:80 email@example.com
Open up a web browser on your local pc and type in http://localhost:8888 and you will
be redirected to your home router on port 80.
If you want to tunnel X through SSH type: ssh -X username@servername.
Once you log in you can type the name of a GUI program (firefox) and it will render in a window on your local machine.
-X allows X forwarding. -x can be used to disable X11 forwarding
Directories from here to there:
scp -r directoryname userid@hostname:directoryname2
Directories from there to here:
scp -r userid@hostname:directoryname2 .