Read the post and watch the videos to learn how to successfully clone a GitHub repository in SAS Studio on SAS Viya using SSH authentication. The content of the post was developed with SAS Viya Long Term Support Release 2022.09, deployed to Azure. You will also learn a few tricks that will save you plenty of research time.
Initially, I tried many times to clone a GitHub repository in SAS Studio on SAS Viya using SSH and failed every time. What worked with SAS Viya 3.5 seemed not to work anymore, for some reason. When I finally succeeded, I learnt that there are a few elements that make all the difference between failure and success.
In this example, SAS Viya is deployed to Azure. On Azure, the SAS Viya deployment comes with a virtual machine called jump-vm.
To generate the SSH keys, I am going to use this virtual machine (VM). The VM has access to folders on a Network File Share
(NFS). The NFS has been mounted in the SAS Compute pod at deployment time.
In SAS Environment Manager, your SAS Administrator must configure these properties for the Git Integration. Follow the link for more details.
The SAS Note 69005 - An SSH authentication fails and you see "...The specified URL or Public SSH key is invalid f... suggests that you are better off generating ECDSA keys when working with GitHub. ECDSA stands for Elliptic Curve Digital Signature Algorithm. RSA SHA-1 keys are no longer supported by GitHub, while ed25519 keys are not supported by SAS. On the Linux machine, for example the jump-vm, generate the ECDSA key:
ssh-keygen -t ecdsa -b 521 -C 'firstname.lastname@example.org'
I chose an empty passphrase, although phrases are supported in SAS Studio.
On the Linux machine where you generated the keys, copy the content of the public key:
ls -la .ssh cat ~/.ssh/id_ecdsa.pub
To use SSH with a GitHub repository, you have to add your public key in your GitHub account. For more information, see Adding a new SSH key to your GitHub account.
The Key text box hints you what type of keys GitHub accepts. I tried initially with a ssh-rsa key and it failed. I tried with an ed25519 key and it also failed, as these are not supported by SAS. Use ecdsa keys.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
To create Git profile in SAS Studio, you would need:
To know if you can reach the GitHub repository and if you are allowed to clone, execute a quick test on your Jump VM:
# clone the git demo repository in a new folder cd /viya-share/azuredm/code ls -la mkdir -p gitrepo1 chmod -R 777 gitrepo1 ls -la cd gitrepo1 git clone email@example.com:bteleuca/git-demo.git cd git-demo ls -la
You should see the cloned repository in a VM folder, proving the SSH clone works.
You can either:
Supposing you go with the first option:
Note that this folder has to be on a Network File Share (SAS Server files). It will not work if your keys are in a folder under SAS Content or My Folder.
From Manage Git connections > Add a Profile. Choose SSH:
From Manage Git connections > Repositories > Clone a repository.
Success Looks Like This
On the Jump VM check the permissions and file ownership.
You will need sudo for this operation:
sudo ls -la /viya-share/azuredm/sshkeys
The ownership of the folder is really important! The number 1803... corresponds to the SAS Viya user identity that created the folder.
At this point the permissions are too wide for SSH keys. To be safe, restrict them to:
sudo chmod 700 /viya-share/azuredm/sshkeys sudo chmod 644 /viya-share/azuredm/sshkeys/id_ecdsa.pub sudo chmod 600 /viya-share/azuredm/sshkeys/id_ecdsa sudo ls -la /viya-share/azuredm/ sudo ls -la /viya-share/azuredm/sshkeys
The objective is to test if you can push some files remotely. Although the clone operation works, you can be sure of your setup only when you manage to push.
Write a SAS program and save it in a folder under your cloned repository:
PROC SORT DATA=sashelp.cars OUT=auto2 ; BY Model ; RUN ; PROC PRINT DATA=auto2 ; RUN ;
In this bonus section, you can watch how to add a repository in SAS Studio or delete a repository.
You can clone a GitHub repository in SAS Studio on SAS Viya. Attention points:
Thank you for your time reading this post. If you liked the post, give it a thumbs up! Please comment and tell us what you think about SAS Studio and Git SSH. If you wish to get more information, please write me an email.
Find more articles from SAS Global Enablement and Learning here.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.