Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
abstract:farber:system_access:linux [2018-05-24 10:53] – anita | abstract:farber:system_access:linux [2021-08-24 13:08] (current) – [Connecting to Farber from Mac/Linux] anita | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Connecting to Farber from Mac/Linux ==== | + | ====== Connecting to Farber from Mac/ |
//This section uses the wiki's [[:# | //This section uses the wiki's [[:# | ||
- | To initiate an SSH connection from a Linux system to the cluster' | + | To initiate an SSH connection from a Mac/Linux system to the cluster' |
the generic command | the generic command | ||
Line 13: | Line 13: | ||
</ | </ | ||
- | This **ssh** command is on your local system. | + | This **ssh** command is on your local system. |
- | <note tip> | ||
- | </ | ||
- | <note tip>**Mac/ | + | ====== SSH Command line mode ====== |
- | When using the recommended setup for [[general/connect/ssh-command-line|command | + | |
+ | The secure shell (SSH) is a network protocol to allow secure logins and file transfers to a remote host. On a PC it is frequently bundled with a terminal emulator, as a place to type commands on the remote host. Unix systems, include | ||
+ | |||
+ | - **SSH** - to start a secure shell connection, and typically login to the remote machine. | ||
+ | - **SFTP** - to open a session on the remote machine to browse the filesystem, and transfer files. | ||
+ | - **SCP** - to copy files or directories directly, when you know the full path of the file name. This one command is similar to the rcp command, and is particularly useful in script, since both the source a destination files need to be completely specified. | ||
+ | |||
+ | All of these commands use the hidden SSH directory to store identity keys, host keys and your configuration file. There are a few SSH command utilities to help you manage your SSH directory. | ||
+ | ===== SSH directory ===== | ||
+ | The SSH commands are Unix commands and they use a hidden directory in your home directory //~/.ssh// to store important files: | ||
+ | * public/ | ||
+ | * List of known host keys (host identities you know) | ||
+ | * List of authorized keys (identities you want to allow in) | ||
+ | * Your personal configuration file | ||
+ | It is very important to have this directory and all the files permitted properly. | ||
+ | |||
+ | To connect to a remote host, you must first exchange identity keys. The remote host has a system level SSH directory /// | ||
+ | |||
+ | ^^ Key exchanges | ||
+ | ^^ On Local Host ^^ ^^ On Remote Host^^ | ||
+ | || ~/ | ||
+ | || ~/.ssh public key file || --->> || ~/ | ||
+ | |||
+ | There are SSH tools to help with the key exchange. | ||
+ | ===== Initializing SSH directory===== | ||
+ | We will map out a basic method | ||
+ | |||
+ | -'' | ||
+ | -'' | ||
+ | -'' | ||
+ | -'' | ||
+ | |||
+ | Repeat the last two steps command | ||
+ | |||
+ | |||
+ | ==== Public/ | ||
+ | |||
+ | First, you want to establish your identity on this new host. You have an account and password that gives you access to your home directory, but you want to add keys to your home directory so you can prove your entity to remote hosts. | ||
+ | |||
+ | ssh-keygen | ||
+ | |||
+ | Here is an example session output where you accepted the default file was accepted, the hidden directory was created, and a non-empty passphrase was entered twice (not displayed). | ||
+ | < | ||
+ | [trainf@farber ~]$ ssh-keygen | ||
+ | Generating public/ | ||
+ | Enter file in which to save the key (/ | ||
+ | Created directory '/ | ||
+ | Enter passphrase (empty for no passphrase): | ||
+ | Enter same passphrase again: | ||
+ | Your identification has been saved in / | ||
+ | Your public key has been saved in / | ||
+ | The key fingerprint is: | ||
+ | ba: | ||
+ | The key's randomart image is: | ||
+ | +--[ RSA 2048]----+ | ||
+ | | | | ||
+ | | | | ||
+ | | | | ||
+ | | .| | ||
+ | | S . +| | ||
+ | | + = . *.| | ||
+ | | + o o . *| | ||
+ | | +.. . ..+E| | ||
+ | | .o+. .+o+. | | ||
+ | +-----------------+ | ||
+ | </ | ||
+ | **Do not enter an empty passphrase**. | ||
+ | with: | ||
+ | < | ||
+ | [trainf@farber ~]$ ls -dl .ssh .ssh/* | ||
+ | drwx------ 2 trainf everyone | ||
+ | -rw------- 1 trainf everyone 1743 Sep 16 16:53 .ssh/ | ||
+ | -rw-r--r-- 1 trainf everyone | ||
+ | </ | ||
+ | |||
+ | ==== Adding keys to SSH agent ==== | ||
+ | |||
+ | Second, you want to add your keys to your SSH agent. | ||
+ | |||
+ | ssh-add | ||
+ | |||
+ | Here is an example session output where you enter the same passphrase you entered above (twice). | ||
+ | < | ||
+ | [trainf@farber ~]$ ssh-add | ||
+ | Enter passphrase for / | ||
+ | Identity added: / | ||
+ | </ | ||
+ | |||
+ | You can list the keys in your SSH agent with: | ||
+ | < | ||
+ | [trainf@farber ~]$ ssh-add -l | ||
+ | 2048 ba: | ||
+ | </ | ||
+ | |||
+ | ==== Adding keys to known host file ==== | ||
+ | |||
+ | To connect to a remote you must know the key and have it stored in your known host file. The | ||
+ | system will do this exchange automatically, | ||
+ | |||
+ | < | ||
+ | [trainf@centos .ssh]$ ssh notme@farber.hpc.udel.edu | ||
+ | The authenticity of host ' | ||
+ | RSA key fingerprint is 19: | ||
+ | Are you sure you want to continue connecting (yes/no)? yes | ||
+ | Warning: Permanently added ' | ||
+ | </ | ||
+ | ==== Copy ID keys to remote host ==== | ||
+ | Third, | ||
+ | |||
+ | ssh-copy-id account@remote_host | ||
+ | |||
+ | |||
+ | <note tip> | ||
+ | a " | ||
+ | For a one time copy of your id, after a local ssh-add, use the command: | ||
+ | |||
+ | ssh -A account@remote_host ' | ||
+ | |||
+ | to append the keys in your agent to the end of your remote authorized keys file. | ||
+ | |||
+ | Or you can copy the relatively simple shell executable (and man page) from a host that does have it installed. | ||
</ | </ | ||
+ | Here is an example session using the ssh-copy-id command. | ||
+ | Answer | ||
+ | " | ||
+ | < | ||
+ | [trainf@farber ~]$ ssh-copy-id jdoe@centos.css.udel.edu | ||
+ | The authenticity of host ' | ||
+ | RSA key fingerprint is d2: | ||
+ | Are you sure you want to continue connecting (yes/no)? yes | ||
+ | Warning: Permanently added ' | ||
+ | jdoe@centos.css.udel.edu' | ||
+ | Now try logging into the machine, with "ssh ' | ||
+ | |||
+ | .ssh/ | ||
+ | |||
+ | to make sure we haven' | ||
+ | </ | ||
+ | |||
+ | In this case, you have " | ||
+ | keys to your remote '' | ||
+ | Check the file permissions and dates with commands: | ||
+ | |||
+ | <code bash> | ||
+ | ls -dl .ssh .ssh/* | ||
+ | ssh jdoe@centos.css.udel.edu 'ls -dl .ssh .ssh/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Create SSH services ==== | ||
+ | |||
+ | An SSH service is a short cut that is saved you ssh configuration file. Collect this information for each service | ||
+ | you want to add: | ||
+ | |||
+ | ^^ Short name ^^ Account name ^^ Full server name ^^ Options you want to add^^ | ||
+ | || farber || trainf || farber.hpc.udel.edu || Trusted X11 tunnelling & arcfour ciphers || | ||
+ | || vm || jdoe || centos.css.udel.edu || no password authentication || | ||
+ | |||
+ | For these two services add these lines to your '' | ||
+ | |||
+ | < | ||
+ | Host farber | ||
+ | User trainf | ||
+ | Hostname farber.hpc.udel.edu | ||
+ | ForwardX11 yes | ||
+ | ForwardX11Trusted yes | ||
+ | Ciphers arcfour256, | ||
+ | Host vm | ||
+ | User jdoe | ||
+ | Hostname centos.css.udel.edu | ||
+ | PasswordAuthentication no | ||
+ | </ | ||
+ | |||
+ | With these lines in your '' | ||
+ | |||
+ | < | ||
+ | ssh farber | ||
+ | </ | ||
+ | | ||
+ | and you can copy files from you current local directory to your remote home directory with the command: | ||
+ | |||
+ | < | ||
+ | scp localfile.txt farber: | ||
+ | </ | ||
+ |