Using rlwrap with an ssh session - ubuntu-10.04

I am using SSH to login to an ubuntu server. However, I am not able to use commands such as tab auto-complete, or using arrow keys to view previous history. I have installed rlwrap on the remote machine and on my local directory. I was wondering if there was any way to use rlwrap to allow me to use these shortcuts on the server (or something else). The server is running Ubuntu Server edition 10.0.4.

Check your shell on the remote server, change it to /bin/bash if it is not
chsh /bin/bash

I have some difficulty understanding your question (e.g. what commands are you running on the remote server? What is your local directory and how does one install rlwrap on it?. Does the input history of your login shell work properly?)
In general:
When an interactive command doesn't have a usable (by way of the arrow keys) input history, type rlwrap in front of the command name. E.g.: rlwrap sqlplus instead of just sqlplus
If you cannot use your arrow keys at all, even in your login shell, something is wrong with your installation. In that case you'll have to ask the remote machine's system administrator to help you. You could run rlwrap ssh remote.host from a shell prompt on your local machine as a stop-gap measure

Related

Pass password through jenkins build step

I'm trying to add a build step in jenkins to copy files from my build server to my web application server. I've got the following command working in the command prompt
sudo scp -r /var/lib/jenkins/workspace/demoproj/publish root#0.0.0.0:/usr/temp
but when I run this command, it prompts me for a password every time. I found out about sshpass, but when I run this command...
sudo sshpass -p "passwordhere" scp -r /var/lib/jenkins/workspace/demoproj/pub root#0.0.0.0:/usr/temp
the terminal gets stuck. And never makes it through.
My main problem is if I add the first command to a build step in jenkins, it won't be able to pass the password over. How can I either supply the password in jenkins, or modify the command to pass over my credentials?
Helpful information: I'm using Putty on Windows 10 to connect to my
Ubuntu 16.04.3 LTS x64 servers from another Ubuntu 16.04.3 server.
First, sshpass needs to be installed on both the systems that is, the one running your jenkins instance as well as the one you are trying to access that is: root#0.0.0.0. You can verify it by doing 'which sshpass' or 'whereis sshpass'. If its not installed even in one of them then you need to install it first.
Also, Have you ever tried doing a ssh to the said machine: root#0.0.0.0 from the system where you have your jenkins instance? If not then there might not be an entry in the 'known-hosts' of either system. for that you can do ssh with '-o StrictHostKeyChecking=no' option to make an automatic entry in known-hosts.
Alternatively, if you dont want to enter password again and again you should work with 'keys'. Generate a unique key for both the systems and do an scp or ssh with -i option.
You should use jenkins credentials instead of using sensitive passwords directly into the scripts. Put the whole scp or ssh part inside a block which looks like: withCredentials(){}.
What's the point of having CI if you are required to be nearby to enter password every time? Install "publish over ssh" plugin, it has a step to send stuff over ssh.
https://wiki.jenkins.io/display/JENKINS/Publish+Over+SSH+Plugin
Look at "Use SSH during a build" section, you can use "send files or execute commands over SSH" build step. This shall become available after plugin installation.

Ubuntu server login loop in shell after deleting zsh

I have a PC I'm using as a linux server (Ubuntu 16.10), to which I ssh / run nginx etc. Today I tried to remove zsh (the default shell, via apt-get purge) hoping it would default back to either to bash or fish shell. Instead, I now cannot ssh into the server (wrong password), and when I use the same password to login directly to the server (as in not via ssh, literally hooking up the server to a monitor) it flashes some text and prompts me to login again.
I've tried holding shift on boot, didn't do anything.
Also, no FTP.
And I don't have a password for the root user or any other user.
I'd heavily prefer not to wipe the whole server, Is there a way I can access it and fix it?
Thanks in advance.
As #Maadinsh said, this is the correct answer:
Boot into a linux liveCD (Ubuntu liveCD, etc.)
Mount the Linux system partition (The boot looped Ubuntu-Server, not the liveCD ubuntu / other distro)
cd into /etc/ and chmod passwd to let you edit it
Change the default shell for your user (at the end of the line) from the nonexisting shell to an existing one.
Save passwd
Reboot the server.

I want to open git bash in a linux server using putty. How will I do that?

I am following this https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git and I am stack on step 5, I want to open git bash in a linux server using putty. How will I do that? In windows, there is gitbash cmd desktop app. But in linux how will you get from normal command line to git bash?
Note: I am using putty to access the linux server. If there is other way also, please recommend me.
“Git bash” under Windows simulates a Linux environment (it uses MinGW behind the scenes, afaik).
Under a Linux distribution, you just have to have a version of Git installed. With a Debian based distribution you would for example run sudo apt-get install git (or git-core for older releases) on the command line.
Once installed, you can use it from the command line without further ado.
Actually Windows gitbash is an emulation of a bash command interpreter designed for UNIX systems. On many Linux distributives bash is a default command shell. So, when you're connecting to a Linux via putty, you're actually entering a bash shell. There's nothing more you need. You can use it the similar way as you're using windows gitbash. In a nutshell, just omit the first item in the spet 5 of your tutorial: you probably already in the bash shell.
To check out which shell you're using, run this command: ps -p $$. It will output something like this:
PID TTY TIME CMD
10967 ttys000 0:01.68 -bash
The CMD field is the shell name you're using.

How to log in into the linux terminal as ROOT user using ruby script

I want to run a script on remote server using SSH.
I have write all the code which runs properly using system command.
To run my code on remote server I need some packages which I need to install on remote server.
To do so I need login into remote terminal as a ROOT user. When I try to do using Ruby script so I get something like following
[not_root_user#remote_server]$ su
Password:
I need some command using which I can able to login into the remote server something like following
[not_root_user#remote_server]$ su -p ******
[root#remote_server]#
Is there any linux command which accepts the password in it?
So you want your script to act as root?
It's not really recommended, but you can use expect: http://en.wikipedia.org/wiki/Expect
The wiki there has a walkthrough for a basic automated telnet session that you could adapt to your needs.
However, you're going to have your root password in plain text, which could be a security issue. If you go that route, I'd definitely obliterate all copies of that script from the universe once this package is installed.
But if you're allowing direct root logins, you've already got a bit of a security problem. Sudo works out-of-the-box on every modern linux distro I've used, I'd stick with that, if possible.
Another option which is equally tasteless would be to set up root-to-root login without a password via ssh.
Sudo would be my first option to getting around this. Although not the best option.
You can also use Key authentication with SSH, and if password authentication is turned off there is no need to enter a password.

When SSHing into system, is there a way to launch netbeans from command-line like I do VIM?

VIM seems integrated to the terminal. Can I open a remote file from the command-line with netbeans? Does it have shell integration? Any further explanation on this so I can better conceptually understand it would be very appreciated.
Few options:
Using ssh -X to forward X. Then you
can start netbeans remotely.
Use sshfs so you mount the
remote filesystem locally over ssh.
You can use then local copy of
netbeans to work on remote files.
Using rsync to have a local copy
The best one - use version control
Yes, you can, providing certain conditions are met!
Using ssh, you can tunnel the display of X-Window applications, meaning you can run the application (the X-Client) on one machine, and have it display on another (the X-Server).
You'll need to launch ssh with the -X option (or -Y, but preferably -X) to allow tunnelling, and then run NetBeans from the commandline as usual:
netbeans MyFile.java
Read about X-forwarding. The link points to a very verbose and detailed howto/tutorial.

Resources