---+ SSH configuration for Mac and Linux # goto your homedirectory <verbatim>cd</verbatim> # create a .ssh directory <verbatim>mkdir .ssh</verbatim> # goto .ssh directory <verbatim>cd ~/.ssh</verbatim> # create a ssh keypair <verbatim>ssh-keygen -t rsa -C HPC -f id_rsa_hpc</verbatim> # enter 2 times a secret word called "passphrase" <br /> # Put this passphrase in a "digital safe" ( p.e. *<noautolink>KeepAss</noautolink>* see: https://keepass.info/ ) because you need this later on. # now you created 2 files like this -rw------- 1 wvanburen users 1766 Mar 27 11:47 id_rsa_hpc<br /> -rw-r--r-- 1 wvanburen users 385 Mar 27 11:47 id_rsa_hpc.pub<br /> # copy and paste the content of the public-key named id_rsa_hpc.pub <br/> # and mail this to hpc-systems@lists.umcutrecht.nl<br/> # After the admins configured your public key on the gateway you can try to login into the hpc gateway by<br/> <verbatim>ssh -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl</verbatim> (Give only once a Yes to add the serverkey to your know_hosts file in your .ssh directory) and enter your selfmade passphrase.<br/> Once you entered the gateway you can continue to log in into the HPC by: <verbatim>ssh hpcs03</verbatim> or <verbatim>ssh hpcs04</verbatim> and answer with your HPC-password And you are on the HPC now You can automate this procedure to create a ssh-config files called "config" in your .ssh directory.<br/> This is an example. <br/> Copy and save this file in the .ssh directory and call it config. <verbatim> ############################################# # file : ~/.ssh/config # date : 20200327 # expl : default ssh config file example ############################################# # usage : ssh hpcgw Host hpcgw HostName hpcgw.op.umcutrecht.nl User wvanburen Protocol 2 Port 22 IdentityFile ~/.ssh/id_rsa_hpc # usage : ssh gw2hpcs03 Host gw2hpcs03 HostName hpcs03.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ProxyCommand ssh -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh gw2hpcs03X Host gw2hpcs03 HostName hpcs03.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ForwardX11 yes ProxyCommand ssh -X -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh gw2hpcs04 Host gw2hpcs04 HostName hpcs04.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ProxyCommand ssh -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh gw2hpcs04X Host gw2hpcs04 HostName hpcs04.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ForwardX11 yes ProxyCommand ssh -X -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh gw2hpct01 Host gw2hpct01 HostName hpct01.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ProxyCommand ssh -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh gw2hpct02 Host gw2hpct02 HostName hpct02.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ProxyCommand ssh -i ~/.ssh/id_rsa_hpc -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh hpcs03 Host hpcs03 HostName hpcs03.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 # usage : ssh hpcs03X Host hpcs03X HostName hpcs03.op.umcutrecht.nl User wvanburen Port 22 ForwardX11 yes # usage : ssh hpcs04 Host hpcs04 HostName hpcs04.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 # usage : ssh hpcs04X Host hpcs04X HostName hpcs04.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 ForwardX11 yes # usage : ssh hpct01 Host hpct01 HostName hpct01.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 # usage : ssh hpct02 Host hpct02 HostName hpct02.op.umcutrecht.nl User wvanburen Port 22 Protocol 2 # usage : ssh ft_gw2hpct01 # then start a filezilla session on localhost # for filetransfer from hpct01 to local machine Host ft_gw2hpct01 HostName hpct01.op.umcutrecht.nl User wvanburen Protocol 2 ProxyCommand ssh -X -i ~/.ssh/id_rsa_hpc -L 8888:hpct01.op.umcutrecht.nl:22 -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null # usage : ssh ft_gw2hpct02 # then start a filezilla session on localhost # for filetransfer from hpct01 to local machine Host ft_gw2hpct02 HostName hpct02.op.umcutrecht.nl User wvanburen Protocol 2 ProxyCommand ssh -X -i ~/.ssh/id_rsa_hpc -L 8888:hpct02.op.umcutrecht.nl:22 -l wvanburen hpcgw.op.umcutrecht.nl nc %h %p 2>/dev/null #########################################</verbatim> With this oneliner you can replace *wvanburen* in your own *username* int the file *"~/.ssh/config"* <verbatim>sed -i 's/wvanburen/my_username/' ~/.ssh/config </verbatim> Try <verbatim>ssh gw2hpcs04 </verbatim> It will ask for your passphrase on the gateway _hpcgw_ followed by your hpc-password on _hpcs04_ . -- %USERSIG{ReneJanssen - 2020-03-27}%
This topic: HPC
>
WebHome
>
FirstTimeUsers
>
SshCommandLine
Topic revision: r2 - 2020-03-27 - ReneJanssen
Copyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback