Guest User

naveen/fileiooperations

a guest
Nov 12th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. [root@ol4 ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. centos_v1 default 8269dafdd9f8 2 weeks ago 196.7 MB
  4. nginx latest e43d811ce2f4 3 weeks ago 181.4 MB
  5. centos 7 980e0e4c79ec 9 weeks ago 196.7 MB
  6. centos latest 980e0e4c79ec 9 weeks ago 196.7 MB
  7. [root@ol4 ~]# clear
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. [root@ol4 ~]# python
  37. Python 2.7.5 (default, Sep 14 2016, 08:35:31)
  38. [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
  39. Type "help", "copyright", "credits" or "license" for more information.
  40. >>> cmd1='hostname'
  41. >>> cmd2='docker images'
  42. >>> srvr='rhel1'
  43. >>> srvr1='ol4'
  44. >>> ssh=paramiko.SSHClient()
  45. Traceback (most recent call last):
  46. File "<stdin>", line 1, in <module>
  47. NameError: name 'paramiko' is not defined
  48. >>> import paramiko
  49. >>> ssh=paramiko.SSHClient()
  50. >>> ssh.set_missing_host_key_policy(paraniko.AutoAddPolicy())
  51. Traceback (most recent call last):
  52. File "<stdin>", line 1, in <module>
  53. NameError: name 'paraniko' is not defined
  54. >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  55. >>> ssh.connect(srvr,username='root')
  56. >>> stdin,stdout,stderr=ssh.exec_command(cmd1)
  57. >>> stdout
  58. <paramiko.ChannelFile from <paramiko.Channel 0 (closed) -> <paramiko.Transport at 0x2a17c50L (cipher aes128-ctr, 128 bits) (active; 0 open channel(s))>>>
  59. >>> stdout.readlines()
  60. [u'rhel1\n']
  61. >>> stderr.readlines()
  62. []
  63. >>> cmd3='hotname'
  64. >>> ssh.close()
  65. >>> ssh=paramiko.SSHClient()
  66. >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  67. >>> ssh.connect(srvr,username='root')
  68. >>> stdin,stdout,stderr=ssh.exec_command(cmd3)
  69. >>> stdout.readlines()
  70. []
  71. >>> stderr.readlines()
  72. [u'bash: hotname: command not found\n']
  73. >>> ssh.close()
  74. >>> ssh=paramiko.SSHClient()
  75. >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  76. >>> ssh.connect(srvr1,username='root')
  77. Traceback (most recent call last):
  78. File "<stdin>", line 1, in <module>
  79. File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 380, in connect
  80. look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  81. File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 603, in _auth
  82. raise saved_exception
  83. paramiko.ssh_exception.AuthenticationException: Authentication failed.
  84. >>> srvr1
  85. 'ol4'
  86. >>> ssh.connect(srvr1,username='root')
  87. Traceback (most recent call last):
  88. File "<stdin>", line 1, in <module>
  89. File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 380, in connect
  90. look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  91. File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 603, in _auth
  92. raise saved_exception
  93. paramiko.ssh_exception.AuthenticationException: Authentication failed.
  94. >>> exit()
  95. [root@ol4 ~]# ssh ol4
  96. root@ol4's password:
  97. Last login: Sat Nov 12 19:29:34 2016 from rhel1
  98. [root@ol4 ~]# exit
  99. logout
  100. Connection to ol4 closed.
  101. [root@ol4 ~]# pwd
  102. /root
  103. [root@ol4 ~]# ssh
  104. ssh ssh-agent sshd ssh-keygen
  105. ssh-add ssh-copy-id sshd-keygen ssh-keyscan
  106. [root@ol4 ~]# ssh
  107. ssh ssh-agent sshd ssh-keygen
  108. ssh-add ssh-copy-id sshd-keygen ssh-keyscan
  109. [root@ol4 ~]# ssh-copy-id root@ol4
  110. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  111. /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  112. root@ol4's password:
  113.  
  114. Number of key(s) added: 1
  115.  
  116. Now try logging into the machine, with: "ssh 'root@ol4'"
  117. and check to make sure that only the key(s) you wanted were added.
  118.  
  119. [root@ol4 ~]# exit
  120. logout
  121. Connection to ol4 closed.
  122. [root@rhel1 ~]# ssh ol4
  123. Last login: Sat Nov 12 19:34:38 2016 from ol4
  124. [root@ol4 ~]# ssh root@ol4
  125. Last login: Sat Nov 12 19:34:59 2016 from rhel1
  126. [root@ol4 ~]# exit
  127. logout
  128. Connection to ol4 closed.
  129. [root@ol4 ~]# python
  130. Python 2.7.5 (default, Sep 14 2016, 08:35:31)
  131. [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
  132. Type "help", "copyright", "credits" or "license" for more information.
  133. >>> import paramiko
  134. >>> cmd='docker images'
  135. >>> srvr1='ol4'
  136. >>> ssh=paramiko.SSHClient()
  137. >>> ssh.set_missing_host_key_policy(paraniko.AutoAddPolicy())
  138. Traceback (most recent call last):
  139. File "<stdin>", line 1, in <module>
  140. NameError: name 'paraniko' is not defined
  141. >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  142. >>> ssh.connect(srvr1,username='root')
  143. >>> stdin,stdout,stderr=ssh.exec_command(cmd)
  144. >>> stdout.readlines()
  145. [u'REPOSITORY TAG IMAGE ID CREATED SIZE\n', u'centos_v1 default 8269dafdd9f8 2 weeks ago 196.7 MB\n', u'nginx latest e43d811ce2f4 3 weeks ago 181.4 MB\n', u'centos 7 980e0e4c79ec 9 weeks ago 196.7 MB\n', u'centos latest 980e0e4c79ec 9 weeks ago 196.7 MB\n']
  146. >>> a=stdout.readlines()
  147. >>> for item in a:
  148. ... print item
  149. ...
  150. >>> a
  151. []
  152. >>> ssh.close()
  153. >>> ssh=paramiko.SSHClient()
  154. >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  155. >>> ssh.connect(srvr1,username='root')
  156. >>> stdin,stdout,stderr=ssh.exec_command(cmd)
  157. >>> a=stdout.readlines()
  158. >>> a
  159. [u'REPOSITORY TAG IMAGE ID CREATED SIZE\n', u'centos_v1 default 8269dafdd9f8 2 weeks ago 196.7 MB\n', u'nginx latest e43d811ce2f4 3 weeks ago 181.4 MB\n', u'centos 7 980e0e4c79ec 9 weeks ago 196.7 MB\n', u'centos latest 980e0e4c79ec 9 weeks ago 196.7 MB\n']
  160. >>> for line in a:
  161. ... print line
  162. ...
  163. REPOSITORY TAG IMAGE ID CREATED SIZE
  164.  
  165. centos_v1 default 8269dafdd9f8 2 weeks ago 196.7 MB
  166.  
  167. nginx latest e43d811ce2f4 3 weeks ago 181.4 MB
  168.  
  169. centos 7 980e0e4c79ec 9 weeks ago 196.7 MB
  170.  
  171. centos latest 980e0e4c79ec 9 weeks ago 196.7 MB
  172.  
  173. >>> stderr.readlines()
  174. []
  175. >>> ssh.close()
  176. >>> print cmd
  177. docker images
Add Comment
Please, Sign In to add comment