Skip to main content

Posts

Solution for com.jcraft.jsch.JSchException: reject HostKey problem on Ubuntu

Just a random investigation with a workaround. So trying to connect to SFTP server using jsch library, but getting a nasty com.jcraft.jsch.JSchException: reject HostKey exception. This host is already present in ~/.ssh/known_hosts file, so it should not be problem, but it is. It turns out this problem happens if SFTP server is running on Ubuntu and strictHostKey is set to true, but it doesn't happen on Linux Fedora. I suppose this is because host entries in the known_hosts file on Ubuntu are encrypted in a different way than in known_hosts on Fedora, so it cannot be recognized or decrypted by JSch library. Now all you need to do is manually add host entries to the file. Basically you just get the public key for the host where SFTP server is running using this command: ssh-keyscan -t rsa sftp_server_ip_address_or_hostname Then copy-paste the output to your local ~/.ssh/known_hosts file. That's all, it should work now. If it doesn't, try to empty known_hosts file complet...

Setting up SFTP server in Linux Ubuntu. Command line instructions

Simple step-by-step command line instructions on setting up SFTP server in Ubuntu 12.04, based on http://www.thegeekstuff.com/2012/03/chroot-sftp-setup/ article. 1. Add 'sftpusers' group: sudo groupadd sftpusers 2. Create a home directory for 'guestuser' user that will be added at the next step: sudo mkdir /var/guestuserhomedir As the result of the above command permissions for /var/guestuserhomedir should be 755 (owner: root, group: root). 3. Create 'guestuser' user, add it to the 'sftpusers' group and set a new password for this user: sudo useradd -g sftpusers -d /var/guestuserhomedir -s /usr/sbin/nologin guestuser sudo passwd guestuser 4. Create SFTP directories and set permissions (correct permissions are important): sudo mkdir /var/sftp_upload_dir sudo mkdir /var/sftp_upload_dir/guestuser sudo mkdir /var/sftp_upload_dir/guestuser/incoming sudo chown guestuser:sftpusers /var/sftp_upload_dir/guestuser/incoming sudo chmod 777 /var/sftp_u...

Disabling browser "Save As" dialog in Selenium WebDriver tests

How to disable Save As dialog in Selenium WebDriver tests? Solution for Firefox (add more MIME media types if necessary): FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("browser.download.folderList",2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); firefoxProfile.setPreference("browser.download.dir", "/save/file/to/this/directory"); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/html, application/xhtml+xml, application/xml, application/csv, text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream"); WebDriver driver = new FirefoxDriver(firefoxProfile); Solution for Google Chrome (this applies to all MIME media types): Map prefs = new Hashtable (); prefs.put("download.prompt_for_download", "false"); prefs.put("download.default...

Using querySelector in Selenium WebDriver

Sometimes it's very helpful if we are able to click some element directly, by calling JavaScript click event. For example, this can be the case when the element is not visible, or not clickable, thus we cannot use native WebDriver methods. WebDriver driver = new FirefoxDriver(); JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.querySelector('.pane .object_options .dropdown-toggle span').click();");

Accessing your Linux workstation in a corporate network from home PC

Running the following commands assumes that you have already started OpenSSH server at workstation and opened port 22 at your home router. Opening 22 or any other port at workstation is not needed, the only precondition is that you should be able to ping your home PC from the workstation. How to setup SSH tunnel to your workstation from outside corporate network (for example, from home to work)? You should run this command on your workstation: ssh -f -N -q -R 2222:localhost:22 yourhomeusername@yourhomeip Now you can connect from home to your workstation via SSH using this command: ssh -p 2222 yourworkusername@localhost You can even create a fully-functional session on your Linux desktop using No Machine tools ( http://www.nomachine.com/ ). Just install node and server components on your workstation and connect via client from your home PC. A new session will be created. Also you can directly run some programs which require X server (but the interaction speed will be pretty slow) b...

Selenium WebDriver Ruby tutorial

This is a list of very short examples which demonstrate the basic usage of Selenium Webdriver for test automation in Ruby language. Each section includes a sample web page code and automated test code, along with the comments for better understanding. Getting started. WebDriver initialization Working with Element Locators Submitting Forms Page Test Testing Image elements on the page Page Test Setting Checkboxes Page Test Setting Radio Buttons Page Test Selecting Select Boxes Page Test Testing HTML Tables Page Test Executing JavaScript code on the page. Handling popup dialogs Page Test Dealing with the Frames Page Test A single Test Unit Include several Test Units in a Test Suite

How to get upstream job status in Hudson from downstream jobs statuses

This is step-by-step instruction based on this blog: http://fatalfailure.wordpress.com/2011/06/14/jenkins-hudson-getting-the-overall-status-in-the-upstream-job-from-the-downstream-jobs/ Upstream job configuration 1. Adding downstream jobs a) In 'Post-build Actions' section set 'Build other projects' checkbox b) Add downstream jobs in 'Build other projects', separated by comma c) Set 'Trigger even if the build is unstable' 2. Setting up fingerprinting to connect upstream job with downstream jobs a) In 'Post-build Actions' section set 'Record fingerprints of files to track usage' checkbox b) Set '**' in 'Files to fingerprint' field c) Set 'Keep the build logs of dependencies' checkbox Downstream jobs configuration 1. Setting up fingerprinting to connect upstream job with downstream jobs a) In 'Post-build Actions' section set 'Record fingerprints of files to track usage' checkbox b) Set ...