-
Notifications
You must be signed in to change notification settings - Fork 18
Bash and SSH
Your bash environment is configured via the file ~/.bashrc
(or sometimes ~/.bash_profile
).
On NAF machines the default is a zsh shell. If you want to change to bash by default, add
exec bash
to~/.zprofile
If these files to not exist, you can just create them. It is recommended to make use of shared configurations in artus-analysis/bashrc.
The window manager screen is a very useful tool for multiplexing terminals. Start a screen session with
screen
If a screen screen session already exists, you can reattach it with
screen -r [-d]
Inside a screen session you need the following commands:
Ctrl-a c # create a new window
Ctrl-a n # change to next window
Ctrl-a p # change to previous window
Ctrl-a d # detach session, which continues running in the background
You can generate your own key for SSH authentification using one of the two commands
ssh-keygen -t rsa
ssh-keygen -t dsa
This has to be done only once. Then the public key is then installed on any the remote machine with the corresponding command
ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<address of remote machine>
ssh-copy-id -i ~/.ssh/id_dsa.pub <user>@<address of remote machine>
in order to simplify the authentification at this machine. A passwort is then only needed to unlock the key.
If not already existing you create a text file in ~/.ssh/config
. In this file you can then define settings for connections to remote machines. The Host
defines an alias for your SSH connections, such that you can easily connect to a remote machine via ssh naf
, for example. Here is a list of settings that is usually needed in our group:
-
Host naf Hostname = naf-cms.desy.de Compression = yes User = <user> ForwardX11 = yes Host naf1 Hostname = nafhh-cms01.desy.de Compression = yes User = <user> ForwardX11 = yes Host naf2 Hostname = nafhh-cms02.desy.de Compression = yes User = <user> ForwardX11 = yes Host naf3 Hostname = nafhh-cms03.desy.de Compression = yes User = <user> ForwardX11 = yes Host naf4 Hostname = nafhh-cms04.desy.de Compression = yes User = <user> ForwardX11 = yes Host naf5 Hostname = nafhh-cms05.desy.de Compression = yes User = <user> ForwardX11 = yes Host naf6 Hostname = nafhh-cms06.desy.de Compression = yes User = <user> ForwardX11 = yes
-
Host ekplx* Hostname = %h.physik.uni-karlsruhe.de Compression = yes User = <user> ForwardX11 = yes Host ekpcms* Hostname = %h.physik.uni-karlsruhe.de Compression = yes User = <user> ForwardX11 = yes Host ekpams* Hostname = %h.physik.uni-karlsruhe.de Compression = yes User = <user> ForwardX11 = yes
-
Host lx3b* Hostname = %h.physik.rwth-aachen.de Compression = yes User = <user> ForwardX11 = yes ProxyCommand = ssh -l <user> portal.physik.rwth-aachen.de "nc %h 22" Host rwthportal Hostname = portal.physik.rwth-aachen.de Compression = yes User = <user> ForwardX11 = yes Host rwthtunnel Hostname = portal.physik.rwth-aachen.de Compression = yes User = <user> ForwardX11 = yes
-
Host lxplus Hostname = lxplus.cern.ch Compression = yes User = <user> ForwardX11 = yes
Go to menu File
and then Connect to server
and type one of the following lines in the dialog that opens.
ssh://<user>@<remote machine>
ssh://<user>@<remote machine>:/<path>
ssh://<host alias from SSH config>
Then create a bookmark and you can easily edit your files with your favourite local and graphical editor.
Replace all strings matching search
in file file
with replace
:
sed -i -e "s@search@replace@g" file
Delete lines matching search
in file file
:
sed -i -e "@search@d" file