MikroserverSetup: Difference between revisions

From ift
m (Added alternative way to get your files from mikroserver)
(Included Windows X11 forwarding)
 
(6 intermediate revisions by 4 users not shown)
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 long host names.
 
 
'''''NB: This setup is for TSMC, but the commands can be tweaked to be used with IHP or AMS too.'''''
 
 
The three mikroservers are :
* mikroserver1.klientdrift.uib.no
* mikroserver2.klientdrift.uib.no
* mikroserver3.klientdrift.uib.no


There are 4 mikroservers at IFT, mikroserver1 through mikroserver4.


== SSH key ==  
== SSH key ==  
* Generate an 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.
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
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-copy-id USERNAME@mikroserver3.klientdrift.uib.no
== Connection aliases ==


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


== Connection aliases ==
To do this, type "gedit ~/.ssh/config" in the terminal.
This will open up an empty file, and here you can store shorthand 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.


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
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.


alias mikroserver1='ssh -X USERNAME@mikroserver1.klientdrift.uib.no'
== Automatic sourcing ==
alias mikroserver2='ssh -X USERNAME@mikroserver2.klientdrift.uib.no'
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.
alias mikroserver3='ssh -X USERNAME@mikroserver3.klientdrift.uib.no'


Also create another alias for your favourite mikroserver
  echo "source ~/.bashrc" >> ~/.profile
  echo "alias mikroserver='ssh -X USERNAME@mikroserver3.klientdrift.uib.no'" >> ~/.bashrc


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.


== Automatic sourcing ==
== 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 X server software [https://sourceforge.net/projects/xming/ Xming] to enable X11 forwarding. This install comes with PuTTY, an SSH client we will use to connect to the Linux based UiB server.


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
=== Linux/macOS ===
# TSMC setup
The process is the same for both Linux and macOS, except that for macOS you first have to install the X11 server software named [https://www.xquartz.org/ XQuartz].
echo "source /eda/cadence/2016-17/scripts/analog_flow.sh" >> ~/.bashrc
Then, simply connect to the login server by typing
echo "source /eda/cadence/eda_general_init.sh" >> ~/.bashrc
  ssh -Y USERNAME@login.uib.no
# IHP setup
  echo "source ~/ihp/cds/sh.cadence" >> ~/.bashrc


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


The next time you open your terminal on your computer you can type
=== Windows ===
  virtuoso_tsmc
Install Xming and make sure you include PuTTY in the install. Run Xming. It will start minimized, and does not require any setup.
to start Cadence Virtuoso, or
When first opening PuTTY, you will be presented with this configuration menu. Fill in the hostname "login.uib.no", but don't connect yet.
  mikroserver
  [[File:Puttylogin.png]]
to connect to mikroserver3 without any hassle!
Navigate to Connection -> SSH -> X11, and check Enable X11 forwarding, and type in "localhost:0.0" as X display location.
  [[File:Puttyx11.png]]
Return to Session, and make sure connection type is set to SSH. Press "Default Settings" and Save to save this configuration for later. Press Open to connect to the server. Enter your username and password, and now you should be in the Linux terminal for the UiB login server. Try to run "gedit" to confirm that you can run a graphical interface. From here you can ssh to the mikroservers and launch software as on the lab computer. Confirm by running gedit on the mikroserver as well to see that you can tunnel X11 through the login server correctly.


== Add mikroserver as a folder on your pc ==
== 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:
Open up your home folder in Linux and in the bottom left  corner click "Connect to Server" as shown in this picture:
[[File:ConnectToServer.png|thumbnail]]
[[File:ConnectToServer.png|thumbnail]]


as server address type:
as server address type:
  sftp://mikroserver3.ift.uib.no/home/USERNAME
  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 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.
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==  
=== Alternative way using scp/secure copy===
If for some reason the above doesn’t work you can try this:
If for some reason the above doesn’t work you can try this:
* connect to your mikroserver (ssh mikroserver3)
* connect to your mikroserver (ssh mikroserver3)
* locate the file you want to copy. i.e /home/fredrik/picture.jpg
* locate the file you want to copy. i.e /home/USERNAME/picture.jpg
* type this command
* type this command
  scp picture.jpg USERNAME@login.uib.no:~
  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
* 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 ==  
== 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 "fli091"
* Make sure you have replaced all the instances of USERNAME with your usename, i.e "abc0123"
 


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

Latest revision as of 12:44, 3 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 long 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 aliases 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 shorthand 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 X server software Xming to enable X11 forwarding. This install comes with PuTTY, an SSH client we will use to connect to the Linux based UiB server.

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

Install Xming and make sure you include PuTTY in the install. Run Xming. It will start minimized, and does not require any setup. When first opening PuTTY, you will be presented with this configuration menu. Fill in the hostname "login.uib.no", but don't connect yet.

Puttylogin.png

Navigate to Connection -> SSH -> X11, and check Enable X11 forwarding, and type in "localhost:0.0" as X display location.

Puttyx11.png

Return to Session, and make sure connection type is set to SSH. Press "Default Settings" and Save to save this configuration for later. Press Open to connect to the server. Enter your username and password, and now you should be in the Linux terminal for the UiB login server. Try to run "gedit" to confirm that you can run a graphical interface. From here you can ssh to the mikroservers and launch software as on the lab computer. Confirm by running gedit on the mikroserver as well to see that you can tunnel X11 through the login server correctly.

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"