MikroserverSetup: Difference between revisions

From ift
m (Removed full path references)
(Fjernet oppsett av Cadence fra artikkelen siden det dekkes av andre artikler (og stoffet var utdatert). Ryddet opp generelt.)
Line 1: Line 1:
= Set-up of connection to mikroservers and cadence virtuoso  =  
= Setup of connection to mikroservers=  


This set-up will allow you to connect to the mikroservers and/or start Cadence virtuoso with one command without typing any password or host-names.
This setup process will allow you to connect to the mikroservers with one command without typing any password or host-names.


There are 4 mikroservers at IFT, mikroserver1 through mikroserver4.


'''NB: This setup is for TSMC, but the commands can be tweaked to be used with IHP or AMS too.'''
== SSH key ==
To login to the server without having to type in your password every time, we can use SSH key pairs. The public key is stored on the server, and you have your private key stored on the UiB login server.


There are 4 mikroservers, mikroserver1-mikroserver4
To generate a key, type into the terminal
ssh-keygen 
This will generate the files id_rsa and id_rsa.pub in the folder ~/.ssh, where the latter is the public key that needs to be stored on the server. Copy the key with your identity to either mikroserver (mikroserver3 is chosen in this example, but since the user environment is shared for each server, this will give you access to all the servers). You can do this manually, but the easiest way is to use the ssh-copy-id utility. NB: Replace USERNAME with your username
ssh-copy-id USERNAME@mikroserver3.ift.uib.no
You will be prompted your password. After the key is copied, you should be able to login with "ssh USERNAME@mikroserver3.ift.uib.no" without having to enter your password.


== SSH key ==  
== Connection aliases ==
* Generate an ssh-key
ssh-keygen -f ~/.ssh/id.rsa -t rsa -N ''


* Copy the key with your identity to your chosen mikroserver (mikroserver3 is chosen in this example). NB: Replace USERNAME with your user name
Now that you can login without typing your password, it is also convenient to set up host names for the servers to connect quicker.


  ssh-copy-id USERNAME@mikroserver3
To do this, type "gedit ~/.ssh/config" in the terminal.
This will open up an empty file, and here you can store short names and specific SSH settings for the connection, such as your username.
  Host mikroserver3
    HostName mikroserver3.ift.uib.no
    User USERNAME
    Port 22
    ForwardX11 yes
    ForwardX11Trusted yes
Copy and repeat this for each server in the same file, remembering to change the hostname to the corresponding mikroserver for each entry. ForwardX11 allows you to launch software on the server itself, while displaying the GUI remotely to the lab PC.


After saving the file, you should be able to simply write "ssh mikroserver3" in the terminal to login to mikroserver3.
Note: If you are attempting to do this step remotely from the UiB login server you need to use a terminal-based editor like Vim, or connect to the login-server with
ssh -Y USERNAME@login.uib.no
to enable the use of graphical editors such as gedit.


== Connection aliases ==
== Automatic sourcing ==
 
There are two main files of sourcing scripts in a Linux environment. One is the file .bashrc, and the other is the file .profile. The difference in these is that the contents of .profile is executed upon login, and .bashrc is executed every time you access the terminal. .bashrc is not sourced to the system by itself upon login, so we need to source .bashrc in .profile manually to use it. This must be done after connecting to one of the mikroservers.
For ease of use set up aliases for the connections in your terminal. Open .bashrc in a text editor (vim / nano) and type in this


  alias mikroserver1='ssh -X USERNAME@mikroserver1'
  echo "source ~/.bashrc" >> ~./profile
alias mikroserver2='ssh -X USERNAME@mikroserver2'
alias mikroserver3='ssh -X USERNAME@mikroserver3'


Also create another alias for your favourite mikroserver
Scripts can be sourced either within .profile or .bashrc. This will make sure the scripts are loaded every time you log in, so you don't have to do it manually every time.  
echo "alias mikroserver='ssh -X USERNAME@mikroserver3'" >> ~/.bashrc


== Accessing the lab software remotely on your private PC ==
You do not need to set up a VPN to access the lab software from home. By connecting to the mikroservers through the UiB loginserver with X11 forwarding enabled, you can run the software from any network. You can do this directly on Linux/macOS by using SSH in the bash terminal. For Windows, you will need to download the TTY software [https://www.putty.org/ PuTTY] to enable X11 forwarding.


== Automatic sourcing ==
=== Linux/macOS ===
The process is the same for both Linux and macOS, except that for macOS you first have to install the X11 server software named XQuartz.
Then, simply connect to the login server by typing
ssh -Y USERNAME@login.uib.no


Source scripts inside .bashrc. This will make sure the scripts are loaded every time you log in, so you don't have to do it manually
The -Y enables trusted X11 forwarding. From here, you can "ssh mikroserver3" just as you would from the lab PC and run software. The steps described above (SSH keys and config files) can be repeated on your personal Linux/macOS PC to simplify connecting to the UiB loginserver. On Linux, the configuration file is located in "~/.ssh/config" just as on the server, while on macOS it is located in "/private/etc/ssh/ssh_config".
# TSMC setup
echo "source /eda/cadence/2018-19/scripts/analog.sh" >> ~/.bashrc
echo "source /eda/cadence/eda_general_init.sh" >> ~/.bashrc
# IHP setup
echo "source ~/ihp/cds/sh.cadence" >> ~/.bashrc


== Commands to run virtuoso remotely ==  
=== Windows ===
Then finally on the computers in the lab (NOT connected to the mikroservers)
echo "alias virtuoso_tsmc="ssh -X USERNAME@mikroserver3 'cd tsmc;virtuoso &'"" >> ~/.bashrc
echo "alias virtuoso_ihp="ssh -X USERNAME@mikroserver3 'cd ihp/cds;virtuoso &'"" >> ~/.bashrc


The next time you open your terminal on your computer you can type
virtuoso_tsmc
to start Cadence Virtuoso, or
mikroserver
to connect to mikroserver3 without any hassle!


== Add mikroserver as a folder on your pc ==
== Add mikroserver as a folder on your pc ==
Line 70: Line 74:


== Troubleshooting ==  
== Troubleshooting ==  
* Make sure you copy your ID (ssh-copy-id) to the correct mikroserver
* Make sure you have restarted your terminal (or source ~/.bashrc) if the commands doesn't work
* Make sure you have restarted your terminal (or source ~/.bashrc) if the commands doesn't work
* You have to be either connected to the UiB VPN or run the commands via the computers in the lab to be able to connect to microserver
* You have to be either connected to the UiB loginserver or run the commands via the computers in the lab to be able to connect to the mikroservers
* If you are using another shell like zsh or csh the aliases has to be in ~/.zshrc or  ~/.cshrc instead of ~/.bashrc
* If you are using another shell like zsh or csh the aliases has to be in ~/.zshrc or  ~/.cshrc instead of ~/.bashrc
* Make sure you have replaced all the instances of USERNAME with your usename, i.e "abc0123"
* Make sure you have replaced all the instances of USERNAME with your usename, i.e "abc0123"


[[Category:Mikroelektronikk]]
[[Category:Mikroelektronikk]]

Revision as of 14:24, 2 May 2020

Setup of connection to mikroservers

This setup process will allow you to connect to the mikroservers with one command without typing any password or host-names.

There are 4 mikroservers at IFT, mikroserver1 through mikroserver4.

SSH key

To login to the server without having to type in your password every time, we can use SSH key pairs. The public key is stored on the server, and you have your private key stored on the UiB login server.

To generate a key, type into the terminal

ssh-keygen  

This will generate the files id_rsa and id_rsa.pub in the folder ~/.ssh, where the latter is the public key that needs to be stored on the server. Copy the key with your identity to either mikroserver (mikroserver3 is chosen in this example, but since the user environment is shared for each server, this will give you access to all the servers). You can do this manually, but the easiest way is to use the ssh-copy-id utility. NB: Replace USERNAME with your username

ssh-copy-id USERNAME@mikroserver3.ift.uib.no

You will be prompted your password. After the key is copied, you should be able to login with "ssh USERNAME@mikroserver3.ift.uib.no" without having to enter your password.

Connection aliases

Now that you can login without typing your password, it is also convenient to set up host names for the servers to connect quicker.

To do this, type "gedit ~/.ssh/config" in the terminal. This will open up an empty file, and here you can store short names and specific SSH settings for the connection, such as your username.

Host mikroserver3
    HostName mikroserver3.ift.uib.no
    User USERNAME
    Port 22
    ForwardX11 yes
    ForwardX11Trusted yes

Copy and repeat this for each server in the same file, remembering to change the hostname to the corresponding mikroserver for each entry. ForwardX11 allows you to launch software on the server itself, while displaying the GUI remotely to the lab PC.

After saving the file, you should be able to simply write "ssh mikroserver3" in the terminal to login to mikroserver3. Note: If you are attempting to do this step remotely from the UiB login server you need to use a terminal-based editor like Vim, or connect to the login-server with

ssh -Y USERNAME@login.uib.no

to enable the use of graphical editors such as gedit.

Automatic sourcing

There are two main files of sourcing scripts in a Linux environment. One is the file .bashrc, and the other is the file .profile. The difference in these is that the contents of .profile is executed upon login, and .bashrc is executed every time you access the terminal. .bashrc is not sourced to the system by itself upon login, so we need to source .bashrc in .profile manually to use it. This must be done after connecting to one of the mikroservers.

echo "source ~/.bashrc" >> ~./profile

Scripts can be sourced either within .profile or .bashrc. This will make sure the scripts are loaded every time you log in, so you don't have to do it manually every time.

Accessing the lab software remotely on your private PC

You do not need to set up a VPN to access the lab software from home. By connecting to the mikroservers through the UiB loginserver with X11 forwarding enabled, you can run the software from any network. You can do this directly on Linux/macOS by using SSH in the bash terminal. For Windows, you will need to download the TTY software PuTTY to enable X11 forwarding.

Linux/macOS

The process is the same for both Linux and macOS, except that for macOS you first have to install the X11 server software named XQuartz. Then, simply connect to the login server by typing

ssh -Y USERNAME@login.uib.no

The -Y enables trusted X11 forwarding. From here, you can "ssh mikroserver3" just as you would from the lab PC and run software. The steps described above (SSH keys and config files) can be repeated on your personal Linux/macOS PC to simplify connecting to the UiB loginserver. On Linux, the configuration file is located in "~/.ssh/config" just as on the server, while on macOS it is located in "/private/etc/ssh/ssh_config".

Windows

Add mikroserver as a folder on your pc

Open up your home folder in linux and in the bottom left corner click "Connect to Server" as shown in this picture:

ConnectToServer.png

as server address type:

sftp://mikroserver3/home/USERNAME

to add your homefolder on mikroserver as a folder on your local PC for easy access to your files (for example the Transistor_operating_point_printer) To store this connection, right click the "mikroserver3"-folder and click "Add Bookmark". The next time you just click the bookmark to open it.

Alternative way using scp/secure copy

If for some reason the above doesn’t work you can try this:

  • connect to your mikroserver (ssh mikroserver3)
  • locate the file you want to copy. i.e /home/USERNAME/picture.jpg
  • type this command
scp picture.jpg USERNAME@login.uib.no:path/to/folder/to/copy/to
  • this will copy the file to your home folder on any UiB machine
  • To copy a folder
scp -r NameOfFolder USERNAME@login.uib.no:path/to/folder/to/copy/to

Troubleshooting

  • Make sure you have restarted your terminal (or source ~/.bashrc) if the commands doesn't work
  • You have to be either connected to the UiB loginserver or run the commands via the computers in the lab to be able to connect to the mikroservers
  • If you are using another shell like zsh or csh the aliases has to be in ~/.zshrc or ~/.cshrc instead of ~/.bashrc
  • Make sure you have replaced all the instances of USERNAME with your usename, i.e "abc0123"