Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts

Saturday, 18 October 2014

user is not in the sudoers file. This incident will be reported

Part of my testing, there are many best practices in hardening the server and part of it are not to allow "root" access via SSH. As root is common username for a Linux/Unix based system. So I decided to create a user and give it root privileges as I wanted to have complete access of the server. However we can provide limited access to user we want to create.

[root@linux ~]# useradd newuser
[root@linux ~]# passwd newuser
Changing password for user newuser.
New password: "enterpassword"
Retype new password:"enterpassword"
after creating the user when you try to sudo and use command you will face following error "newuser is not in the sudoers file.  This incident will be reported"
[root@linux ~]# su newuser
[ammar@panel root]$ sudo -s
[sudo] password for newuser:
ammar is not in the sudoers file. This incident will be reported.
go to 
[root@panel ~]# nano /etc/sudoers
add following line:
newuser   ALL=(ALL)       ALL      (note: this will grant all privileges to user newuser 

Hope it helps !

Saturday, 2 August 2014

Force logout a user in Linux or Unix

There can be several users logged in Linux/Unix system and they all have different sessions.
[root@linux]# w
10:23:27 up 4:40, 4 users, load average: 1.44, 1.29, 1.27
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 xxx.xx.xxx.xx 05:44 3:04m 0.12s 0.12s -bash
root pts/2 xxx.xx.xxx.xx 05:46 4:37m 0.06s 0.06s -bash
root pts/3 xxx.xx.xxx.xx 05:46 4:37m 0.06s 0.06s -bash
root pts/4 xxx.xx.xxx.xx 06:49 0.00s 0.27s 0.00s w
[root@linux]#
(Where xxx.xx.xxx.xx is the IP from where connections are made.

You can find the process of the session by following command:
ps -dN|grep pts/3 (Where pts3 is seesion no.)
after entering the above command following output will come:
15552 pts/3 00:00:00 bash
Then you can kill the process by:
kill -9 15552
That session will be terminated. Hope it helps !

Force logout a user in Linux or Unix

Friday, 27 June 2014

error-pam-authentication-error-for-root-when-trying-to-ssh-to-freebsd-server-as-root

By default ssh is disabled in Freebsd and work around is shared my one of my posts, http://www.zyraxtech.com/2014/06/permission-denied-keyboard-interactive-authentication/ :
However We faced an issue with one of our old server who’s ssh was configured, by one of the lines were changed mistakenly which caused following error:
error: PAM: authentication error for root from 192.168.XXX.XXX
following lines were checked and changed:
PermitRootLogin yes 
PasswordAuthentication yes 
AllowUsers vht
to
AllowUsers root
NOTE: allowuser line was mistakenly changed.
Hope this helps !

Saturday, 7 June 2014

Permission Denied keyboard-interactive authentication

By default Freebsd has root ssh disabled. Even in Ubuntu 14.04 it is not allowed with some other linux/unix distros as well.
Following error we get on screen even after entering correct password:
freebsd root ssh
To overcome this issue edit following ssh file: (ee is editor in freebsd)
ee /etc/ssh/sshd_config
in the file remove # from port 22
and remove # from
PermitRootLogin no
to
PermitRootLogin yes
then restart sshd demon
/etc/rc.d/sshd restart 

Remote host identification has changed

Normally this issue has a simple solution but people tend not to read whats is required to eliminate the error:
When you run the ssh command following error is received:
ssh issueto remove this error, you just need to edit single line on the following path (I am using nano as editor):
 nano /root/.ssh/known_hosts
ssh issue1Remove the line which corresponds to the IP address which you were trying to access via ssh. save the file and again try to ssh.

Saturday, 26 April 2014

Copy files from linux to another linux server

There are other ways to copy files from a linux server to another linux server. We can use ftp protocol as well but that requires configuration. easiest way is to transfer files using scp.
Scp means “secure copy” it is based on SSH protocol which itself is secure protocol. To transfer files from Windows machine to linux or vice versa there is a software called winscp which can be easily install on windows machine. and it can transfer files to and from Linux server.
To copy files from one linux machine to another following methods is used:
[root@centos]#scp
-bash: scp: command not found
 “this means that scp rpm is not installed on the server. package openssh-clients needs to installed”
[root@centos]# yum install openssh-clients –y
“to install rpm”
To copy file use:
Scp /home/testfile.txt root@serverip:/home/
” to copy files from server you are logged in to a remote server”where serverip can be hostname of that server or what ever the ip that server has.”
To copy directory and all it content we use:
Scp -r /home/testdir root@serverip:/home/dir
” to copy directory and all its content we use the above command”

Tuesday, 3 December 2013

How to access System VMs in Cloudstack

Recently I have been working in managing Cloudstack at my work.  Cloudstack uses 3 types of system VMs for its operation.
1. SSVM - Secondary storage VM: This VM basically mounts the secondary storage which is used for templates, snapshots, ISO for cloudstack.
2. CP - Console Proxy VM: This VM is used basically to view the console (Type of VNC View) of the machine as it is not a physical machine and for access off VM if network is unreachable.
3. VR - Virtual Router:This VM is generated when any account user creates a VM and every VM requires a network, which secures network of that account and access to VMs of that particular user. It also provides DHCP services to make that VM traffic reach the WWW and vice verse.

We continuously require access to these VM mostly VR and SSVM for different debugging (will be updating blog about cloudstack extensively) and for operations.

To access these VMs we need to access the Host they are in which we can find from VMs details

we can find the details of host as well as the link local IP from which we can access without the need of password by going in infrastructure -> System VM or Virtual Router and details will be displayed as above. 

Simply access the host in which VM is and run following command:

ssh -i /root/.ssh/id_rsa.cloud -p 3922 root@169.254.x.x
Where x.x refers to IP which changes from time to time but first two octets are same always.!

After running the above command it will not ask for any username and password and VM can be accessed through this command.
(Hope it Helps !)


Wednesday, 27 November 2013

SecureCRT delete key not working in SSH

Recently I have been looking for tool that would keep my passwords save for linux machine that I access. there are several tools that can be used for this like putty connection manager, SecureCRT.

I have been using SecureCRT save password and automated login method were working fine but I was facing issue with "del" working as "backspace" key. So I made changes in the logon SSH method:

Go into

Click on properties 



Change the emulation from VT100 to Xterm

and then login. issue will be resolved. Hopefully!